<?php
namespace Home\Controller;
use Think\Controller;
header("Content-type:text/html;charset=utf-8");
class UsersController extends Controller {
	public function _initialize(){
		$uid = $_SESSION['user_id'];
		if(empty($uid)) {
			$hid = I("hid");
			$this->assign("hid",$hid);
			$this->display("Index/login");
		}
	}
	//是否设置安全密码  和  绑定银行卡
	public function is_bang(){
		$uid = I("uuid");
		$data = M('Accountsinfo')
			->where("userid = '{$uid}'")
			->field("insurepass")
			->find();
		
		$cc = M("bankcard")->where("uid = '{$uid}'")->select();
		if(trim($data['insurepass'])=="" && empty($cc)){
			echo 1;die;
		}
		if(trim($data['insurepass'])!="" && empty($cc)){
			echo 2;die;
		}
		if(trim($data['insurepass'])=="" && !empty($cc)){
			echo 3;die;
		}
		if(trim($data['insurepass'])!="" && !empty($cc)){
			echo 4;die;
		}
	}
	public function get_data(){
		$uid = $_SESSION['user_id'];
		$data = M('Accountsinfo')
			->where("userid = '{$uid}'")
			->find();
		return $data;
	}
	public function get_money(){
		$uid = I("uuid");
		$data = M('Accountsinfo')
			->where("userid = '{$uid}'")
			->field("money")
			->find();
		echo json_encode($data);
	}
	public function securityCenter(){
		$adr = GetIpLookup("218.241.82.115");

		$hid = I("hid");
		$uid = $_SESSION['user_id'];
		if(!empty($uid)){
			$wanjia = M('Accountsinfo')->where("userid = {$uid}")->field("utype,mobile,email")->find();

			$info = $this->get_data();
			$date =  M("answer")->where("uid={$uid}")->select();
			$this->assign("dat",$date);
			$this->assign('info',$info);
			$this->assign("hid",$hid);
			$this->assign("wanjia",$wanjia);
			$this->assign("adr",$adr);
			$this->display();
		}
		
    }
	protected function page($total_size = 1, $page_size = 0, $current_page = 1, $listRows = 6, $pageParam = '', $pageLink = '', $static = false) {
		if ($page_size == 0) {
			$page_size = C("PAGE_LISTROWS");
		}

		if (empty($pageParam)) {
			$pageParam = C("VAR_PAGE");
		}

		$page = new \Page($total_size, $page_size, $current_page, $listRows, $pageParam, $pageLink, $static);
		$page->SetPager('Admin', '{first}{prev}&nbsp;{liststart}{list}&nbsp;{next}{last}<span>共{recordcount}条数据</span>', array("listlong" => "4", "first" => "首页", "last" => "尾页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => ""));
		return $page;
	}
	public function personalInfo(){
		$info = $this->get_data();
		$birth = $info["birth"];
		$str = explode("-",$birth);
		$this->assign('str',$str);
		$this->assign('info',$info);
		$this->display();
	}

	//基本信息
	function jiben(){
		if(IS_POST){
			$id = I("id");
			$data["NickName"] = I("nickname");
			$data["sex"] = I("xingbie");
			$year =  I("year");
			$math = I("math");
			$day = I("day");
            $birth =$year."-".$math."-".$day;
			$data["birth"] =$birth;
			$data["qq"] = I("qq");
			M('Accountsinfo')->where(" userid = '{$id}' ")->save($data);
			echo 1;
		}else{
			$id = I("id");
			$data = M('Accountsinfo')->find();
			$this->assign("data",$data);
			$this->assign("id",$id);
			$this->display();
		}
	}
	//等级头衔
	function personalLevel(){
		$id = $_SESSION['user_id'];
		$wanjia = M('Accountsinfo')->where("userid = {$id}")->field("utype")->find();

		$data = M('Accountsinfo')->where(" userid = {$id}")->find();

		if($data['score'] < '10'){
			$bili = '10';
		}elseif('10' <= $data['score'] && $data['score'] < '200'){
			$bili = '200';
		}elseif('200' <= $data['score'] && $data['score'] < '1000'){
			$bili = '1000';
		}elseif('1000' <= $data['score'] && $data['score'] < '10000'){
			$bili = '10000';
		}elseif('10000' <= $data['score'] && $data['score'] < '50000'){
			$bili = '50000';
		}elseif('50000' <= $data['score'] && $data['score'] < '250000'){
			$bili = '250000';
		}elseif('250000' <= $data['score'] && $data['score'] < '1000000'){
			$bili = '1000000';
		}elseif('1000000' <= $data['score'] && $data['score'] < '5000000'){
			$bili = '5000000';
		}elseif('5000000' <= $data['score']){
			$bili = '5000000';
		};

		$baifenbi = ($data["score"]/$bili)*100;


		$this->assign("wanjia",$wanjia);
		$this->assign("baifenbi",$baifenbi);
		$this->assign("data",$data);
		$this->display();
	}

    //换图片
	function upd_image(){
		if(IS_POST){
			$id = I("id");
			$data["avatar"] = I("images");
			M('Accountsinfo')->where(" userid = '{$id}' ")->save($data);
			echo 1;
		}else{
			$id = I("id");
			$this->assign("id",$id);
			$this->display();
		}
	}

     //绑定手机号setMail
	 function setMobile(){
		if(IS_POST){
			$id = $_SESSION['user_id'];
			$yzm = I("yzm");
			$shouji = I("mobile");
			$yanzheng = M("code")->where("mobile='{$shouji}' and code='{$yzm}'")->find();
            if($yanzheng){
				$data["mobile"] = $shouji;
				M('Accountsinfo')->where("userid='{$id}'")->save($data);
				echo 1;
			}else{
				echo 2;
			}
		}else{
			$id = I("id");
			$this->assign("id",$id);
			$this->display();
		}
	}
	 //绑定邮箱
	 function setMail(){
		if(IS_POST){
			$id = $_SESSION['user_id'];
			$email = I("email");
			$yzm = I("yzm");
			$yanzheng = M("code")->where("email='{$email}' and code='{$yzm}'")->find();
			if($yanzheng){
				$data["email"] = $email;
				M('Accountsinfo')->where("userid='{$id}'")->save($data);
				echo 1;
			}else{
				echo 2;
			}
		}else{
			$id = I("id");
			$this->assign("id",$id);
			$this->display();
		}
	}

	 //绑定手机号 发送验证码
	 function examine_message(){
        $mobile = I("mobile");
		$code = yz(6);
		$date = array();
		$date['mobile'] = $mobile;
		$date['code'] = $code;
		$date['ctime'] = time();
		M("code")->add($date);


	 //调用类
	 include ('./public/duanxin/smsapi.class.php');
       //接口账号
		 $uid = 'shifencai';
        //登录密码
		 $pwd = 'www123';

		 /**
		  * 实例化接口
		  *
		  * @param string $uid 接口账号
		  * @param string $pwd 接口密码
		  */
		 $api = new \SmsApi($uid,$pwd);

		 //短信内容
		 $content = '您的验证码是：'.$code.'，有效期为5分钟！【十分彩网】';
        //发送全文模板短信
		 $result = $api->sendAll($mobile,$content);

		 if($result['stat']=='100')
		 {
			 echo 1;
		 }else{
			 echo 2;
		 }
	}

	//绑定邮箱 发送验证码
	function examine_message2(){
		$email = I("email");
		$code = yz(6);
		$date = array();
		$date['email'] = $email;
		$date['code'] = $code;
		$date['ctime'] = time();
		M("code")->add($date);
		$title = "邮箱发送验证码";
		$content = '您的验证码是：'.$code.'，有效期为5分钟！【十分彩网】';
		sendmail($email,$title,$content);
		echo 1;
	}


     //修改密码 确认原密码
     function verifyPwd(){
	   if(IS_POST){
		   $id = I("id");
		   $pass = I("pass");
		   $data= M('Accountsinfo')->where("userid='{$id}'")->field("logonpass")->find();
		   if($pass == trim($data["logonpass"])){
			   echo 0;
		   }else{
			   echo 1;
		   }
	   }else{
		   $id = I("id");
		   $this->assign("id",$id);
		   $this->display();
	   }
   }
     //修改密码
	 function verifyPwd2(){
		if(IS_POST){
			$id = I("id");
			$data["LogonPass"] = I("pass");
			M('Accountsinfo')->where("userid='{$id}'")->save($data);
			echo 1;
		}else{
			$id = I("id");
			$this->assign("id",$id);
			$this->display();
		}
	}

	 //设置安全密码
	 function setSafePwd(){
		if(IS_POST){
			$id = I("id");
			$data["InsurePass"] = I("pass");
			M('Accountsinfo')->where("userid='{$id}'")->save($data);
			echo 1;
		}else{
		//	$id = I("id");
			$is_bang = I("is_bang");
			$id = $_SESSION['user_id'];
			$this->assign("id",$id);
			$this->assign("is_bang",$is_bang);
			$this->display();
		}
	}
	 //修改安全密码 确认原安全密码
	 function verifySafePwd(){
		if(IS_POST){
			$id = I("id");
			$pass = I("pass");
			$data= M('Accountsinfo')->where("userid='{$id}'")->field("insurepass")->find();
			if($pass == trim($data["insurepass"])){
				echo 0;
			}else{
				echo 1;
			}
		}else{
			$id = I("id");
			$this->assign("id",$id);
			$this->display();
		}
	}
	 //修改安全密码密码
	 function verifySafePwd2(){
		if(IS_POST){
			$id = I("id");

			$data["InsurePass"] = I("pass");
			M('Accountsinfo')->where("userid='{$id}'")->save($data);
			echo 1;
		}else{
			$id = I("id");
			$this->assign("id",$id);
			$this->display();
		}
	}

     //设置密保问题
	 function setQuestion(){
		if(IS_POST){
			$id = I("id");
			$data[] = array(
				'uid' => $id,
				'ctime'	=> time(),
				'qid' => I("question1"),
				'answer' => I("anser1"),
			);
			$data[] = array(
					'uid' => $id,
					'ctime'	=> time(),
					'qid' => I("question2"),
					'answer' => I("anser2"),
			);
			$data[] = array(
					'uid' => $id,
					'ctime'	=> time(),
					'qid' => I("question3"),
					'answer' => I("anser3"),
			);

			M("answer")->addAll($data);
			echo 1;
		}else{
			$id = I("id");
			$data = M("question")->select();
			$this->assign("arr",$data);
			$this->assign("id",$id);
			$this->display();
		}
	}
     //验证密保问题
	 function setQuestion_upd(){
		if(IS_POST){
			$id = I("id");
			$data1 = I("data1");
			$data2 = I("data2");
			$data3 = I("data3");

			$us1 = M("answer")->where(" uid={$id} and qid = {$data1['question1']} and answer = {$data1['answer1']}")->field("qid,answer")->find();
			if($us1){
				echo 1;
			}else{
				echo 2;
			}
			$us2 = M("answer")->where(" uid={$id} and qid = {$data2['question2']} and answer = {$data2['answer2']}")->field("qid,answer")->find();
			if($us2){
				echo 1;
			}else{
				echo 2;
			}
			$us3 = M("answer")->where(" uid={$id} and qid = {$data3['question3']} and answer = {$data3['answer3']}")->field("qid,answer")->find();
			if($us3){
				echo 1;
			}else{
				echo 2;
			}
		}else{
			$id = I("id");
			$date =  M("answer")->where("uid = {$id}")->select();
			foreach($date as $v){
				$qid[] = $v["qid"];
			}
			$qids = implode(",",$qid);
			  if($qids){
				  $quest = M("question")->where("id in($qids)")->select();
			  }

			$this->assign("date",$date);
			$this->assign("arr",$quest);
			$this->assign("id",$id);
			$this->display();
		}
	}
     //修改密保问题
	 function setverifyQuestion(){
		if(IS_POST){
			$id = I("id");
			$data[] = array(
					'uid' => $id,
					'ctime'	=> time(),
					'qid' => I("question1"),
					'answer' => trim(I("answer1")),
			);
			$data[] = array(
					'uid' => $id,
					'ctime'	=> time(),
					'qid' => I("question2"),
					'answer' => trim(I("answer2")),
			);
			$data[] = array(
					'uid' => $id,
					'ctime'	=> time(),
					'qid' => I("question3"),
					'answer' => trim(I("answer3")),
			);

			M("answer")->where("uid={$id}")->delete();
			M("answer")->addAll($data);
			echo 1;
		}else{
			$id = I("id");
			$data = M("question")->select();
			$this->assign("arr",$data);
			$this->assign("id",$id);
			$this->display();
		}
	}


     //验证安全密码 //绑定银行卡
	 function manageBankcard(){
		if(IS_POST){
		    $uid = $_SESSION['user_id'];

			$mima = I("mima");//安全密码
			$dat= M('Accountsinfo')
					->where("userid = {$uid} and insurepass = '{$mima}'")
					->find();
			if($dat){
				$data["uid"] = $uid;
				$data["ctime"] = time();
				$data["bankid"] = I("yinhang"); //哪个行
				$data["province"] = I("sheng");//哪个省
				$data["city"] = I("shi");//哪个市
				$data["uname"] = I("name");//名字叫什么
				$data["card"] = I("kahao2");//卡号
				M("bankcard")->add($data);
				echo 1;
			}else{
				echo 0;
			}
		}else{
			$uid = $_SESSION['user_id'];
			$wanjia = M('Accountsinfo')->where("userid = {$uid}")->field("utype")->find();

			$data = M("bankcard")->where("uid = {$uid}")->select();
			$count = count($data);
			if($count>='5'){
				$this->success("总共可以绑定5张银行卡。",U("Users/manageBankcard2"));
			}
			$this->assign("wanjia",$wanjia);
			$this->display();
		}
	}
	 //银行卡列表
	 function manageBankcard2()
	{
		$uid = $_SESSION['user_id'];
		$data = M("bankcard")->where("uid = {$uid}")->select();
		$wanjia = M('Accountsinfo')->where("userid = {$uid}")->field("utype")->find();
		foreach($data as $v){
			$v['card'] = trim($v['card']);
			$card[] = substr($v['card'],-4);
		}
		$count = count($data);
		$this->assign("wanjia", $wanjia);
		$this->assign("count", $count);
		$this->assign("card", $card);
		$this->assign("arra", $data);
		$this->display();
	}
     //银行卡列表
	 function manageBankcard3(){
		$id = I("id");
		$uid = $_SESSION['user_id'];
		$mima = I("mima");//安全密码

		$dat= M('Accountsinfo')
				->where("userid = {$uid} and insurepass = '{$mima}'")
				->find();

		if(empty($dat)){
			echo 0;
		}else{
			echo 1;
		}
	}
	 function manageBankcard_upd(){
		if(IS_POST){
		$id = I("id");
		$uid = $_SESSION['user_id'];
        $data["bankid"] = I("yinhang");
		$data["province"] = I("province");
		$data["city"] = I("city");
		$data["uname"] = I("name");
		$data["card"] = I("kahao2");
		$data["ctime"] = time();

        M("bankcard")->where("id={$id} and uid={$uid}")->save($data);
		$this->success("修改成功",U("Users/manageBankcard2"));
		}else{
			$id = I("id");
			$uid = $_SESSION['user_id'];
			$aa= M("bankcard b")
			    ->join("join ".C("DB_PREFIX")."region r on r.id = b.province")
				->join("join ".C("DB_PREFIX")."region c on c.id = b.city")
				->where("uid = {$uid} and b.id = {$id}")
				->field("b.*,r.name sheng,c.name shi")
				->select();

			$this->assign("aa", $aa);
			$this->display();
		}

	}
     //验证安全问题
     function setQuestion_upd2(){
	if(IS_POST){
		$id = I("id");
		$data1 = I("data1");
		$data2 = I("data2");
		$data3 = I("data3");

		$us1 = M("answer")->where("qid = {$data1['question1']} and answer = {$data1['answer1']}")->field("qid,answer")->find();
		if($us1){
			echo 1;
		}else{
			echo 2;
		}
		$us2 = M("answer")->where("qid = {$data2['question2']} and answer = {$data2['answer2']}")->field("qid,answer")->find();
		if($us2){
			echo 1;
		}else{
			echo 2;
		}
		$us3 = M("answer")->where("qid = {$data3['question3']} and answer = {$data3['answer3']}")->field("qid,answer")->find();
		if($us3){
			echo 1;
		}else{
			echo 2;
		}
	}else{
		$id = $_SESSION['user_id'];
		$date =  M("answer")->where("uid = {$id}")->select();
		foreach($date as $v){
			$qid[] = $v["qid"];
		}
		$qids = implode(",",$qid);
		if($qids){
			$quest = M("question")->where("id in($qids)")->select();
		}
		$this->assign("date",$date);
		$this->assign("arr",$quest);
		$this->assign("id",$id);
		$this->display();
	}
}

     //投注记录
     function BetRecord(){
	$id = $_SESSION['user_id'];
	$wanjia = M('Accountsinfo')->where("userid = {$id}")->field("utype")->find();

	$caizhong = I("lotteryclass");
	$shijian = I("shijian");
	$leixing = I("leixing");
	$p = I("p");

	$where = array();
	$wher = array();
	$where['uid'] = $id;
	$wher['uid'] = $id;
	if(!empty($caizhong)){
		$where['lotteryclass'] = $caizhong;
		$wher['lotteryclass'] = $caizhong;
	}
	//时间判断
	if($shijian == ''){
		$shijian = '1';
	}
	if($shijian == '1'){
		$stime = date('Y-m-d')." 00:00:00";  //今天开始时间
		$etime = date('Y-m-d')." 23:59:59";//今天结束时间
	}elseif($shijian == '2'){
		$stime = date('Y-m-d',strtotime('-1 day'))." 00:00:00";//昨天开始时间
		$etime = date('Y-m-d',strtotime('-1 day'))." 23:59:59";//昨天结束时间
	}elseif($shijian == '3'){
		$stime = date('Y-m-d',strtotime('-7 day'))." 00:00:00";//7天开始时间
		$etime = date('Y-m-d')." 23:59:59";//7天结束时间
	}
	$stimes = strtotime($stime);
	$etimes = strtotime($etime);
   $where['ctime'] = array(array('egt',$stimes),array('elt',$etimes));
   $wher['ctime'] = array(array('egt',$stimes),array('elt',$etimes));
   $this->assign("shijian",$shijian);

//类型判断
	if($leixing == ''){
		$leixing = '0';
	}

	if($leixing == '0'){

	}elseif($leixing == '1'){
		$where['zong_money'] = array('gt',0);
	}elseif($leixing == '2'){
		$where['opencode'] = array('neq',"");
		$where['zong_money'] = array('eq',0);
	}elseif($leixing == '3'){
		$where['opencode'] = array('eq',"");
	}


	//搜索彩票名称
	   $classs = M('lottery_class')->select();
	//列表
	$data1 = M('lottery_add')->where($where)->select();
	$data2 = M('lottery_11x5')->where($where)->select();
    $data3 = M('lottery_fc3d')->where($where)->select();
    $data4 = M('lottery_kl8')->where($where) ->select();
    $data5 = M('lottery_pk10')->where($where)->select();
	$data6 = M('lottery_ssc')->where($where)->select();
	   foreach($data1 as $k=>$v){
		   $data1[$k]['table'] = 1;
	   }
	   foreach($data2 as $k=>$v){
		   $data2[$k]['table'] = 2;
	   }
	   foreach($data3 as $k=>$v){
		   $data3[$k]['table'] = 3;
	   }
	   foreach($data4 as $k=>$v){
		   $data4[$k]['table'] = 4;
	   }
	   foreach($data5 as $k=>$v){
		   $data5[$k]['table'] = 5;
	   }
	   foreach($data6 as $k=>$v){
		   $data6[$k]['table'] = 6;
	   }
    $data = array_merge($data1,$data2,$data3,$data4,$data5,$data6);
		 foreach ($data as $user) {
			 $ages[] = $user['ctime'];
		 }
		 array_multisort($ages, SORT_DESC, $data);
//列表
		 $data11 = M('lottery_add')->where($wher)->select();
		 $data22 = M('lottery_11x5')->where($wher)->select();
		 $data33 = M('lottery_fc3d')->where($wher)->select();
		 $data44 = M('lottery_kl8')->where($wher) ->select();
		 $data55 = M('lottery_pk10')->where($wher)->select();
		 $data66 = M('lottery_ssc')->where($wher)->select();
		 foreach($data11 as $k=>$v){
			 $data11[$k]['table'] = 1;
		 }
		 foreach($data22 as $k=>$v){
			 $data22[$k]['table'] = 2;
		 }
		 foreach($data33 as $k=>$v){
			 $data33[$k]['table'] = 3;
		 }
		 foreach($data44 as $k=>$v){
			 $data44[$k]['table'] = 4;
		 }
		 foreach($data55 as $k=>$v){
			 $data55[$k]['table'] = 5;
		 }
		 foreach($data66 as $k=>$v){
			 $data66[$k]['table'] = 6;
		 }
		 $data00 = array_merge($data11,$data22,$data33,$data44,$data55,$data66);
		 foreach ($data00 as $user) {
			 $ages0[] = $user['ctime'];
		 }
		 array_multisort($ages0, SORT_DESC, $data00);
//分页 begion
	   $count = count($data);
	   if($count==0){
		   $p = 0;
	   }else{
		   if(empty($p)){
			   $p = 1;
		   }
	   }
	$data = array_slice($data,($p-1)*10,10);
    $totalpage = ceil($count/10);
    $page = $this->page($count,10);
 //end

	$touzhu = 0;   //投注钱数
	$zhongjiang = 0; //中奖钱数
		 $zhongjiang2 = 0; //中奖钱数
	$yingli = 0;//盈利钱数
	 foreach($data00 as $v){
		 $touzhu += $v["money"];
		 $zhongjiang2 += $v["zong_money"];
		 $yingli = $zhongjiang2-$touzhu;
	 }

	foreach($data as $v){
		$zhongjiang += $v["zong_money"];
	}

	 foreach($data as $v){
		 $lotteryclass[] = $v["lotteryclass"]; //彩种
		 $ids[] = $v["id"];  //内容
	 }

	//彩种
	$lotteryclasss = implode(",",$lotteryclass);
	if($lotteryclasss){
		$class = M('lottery_class')->where("id in($lotteryclasss)")->select();
	}

	//内容
	$idss = implode(",",$ids);

	if($idss){
		$lottery_add_detail  = M('lottery_add_detail')->where("lottery_add_id in($idss)")->field("lottery_add_id,cal,is_zhong")->select();
		$lottery_11x5_detail = M('lottery_11x5_detail')->where("lottery_11x5_id in($idss)")->field("lottery_11x5_id,cal,is_zhong")->select();
		$lottery_fc3d_detail = M('lottery_fc3d_detail')->where("lottery_fc3d_id in($idss)")->field("lottery_fc3d_id,cal,is_zhong")->select();
		$lottery_kl8_detail = M('lottery_kl8_detail')->where("lottery_kl8_id in($idss)")->field("lottery_kl8_id,cal,is_zhong")->select();
		$lottery_pk10_detail = M('lottery_pk10_detail')->where("lottery_pk10_id in($idss)")->field("lottery_pk10_id,cal,is_zhong")->select();
		$lottery_ssc_detail = M('lottery_ssc_detail')->where("lottery_ssc_id in($idss)")->field("lottery_ssc_id,cal,is_zhong")->select();
	}

	$a1 = array();
	foreach($lottery_add_detail as $v){
		//内容
		if(isset($a1[$v["lottery_add_id"]])){
			$a1[$v["lottery_add_id"]] = $a1[$v["lottery_add_id"]].'#'.$v["cal"];
		}else{
			$a1[$v["lottery_add_id"]] = $v["cal"];
		}
	}

	$a2 = array();
    foreach($lottery_11x5_detail as $v){
	   //内容
	   if(isset($a2[$v["lottery_11x5_id"]])){
		   $a2[$v["lottery_11x5_id"]] = $a2[$v["lottery_11x5_id"]].'#'.$v["cal"];
	   }else{
		   $a2[$v["lottery_11x5_id"]] = $v["cal"];
	   }
   }
	   $a3 = array();
	   foreach($lottery_fc3d_detail as $v){
		   //内容
		   if(isset($a3[$v["lottery_fc3d_id"]])){
			   $a3[$v["lottery_fc3d_id"]] = $a3[$v["lottery_fc3d_id"]].'#'.$v["cal"];
		   }else{
			   $a3[$v["lottery_fc3d_id"]] = $v["cal"];
		   }
	   }
	   $a4 = array();
	   foreach($lottery_kl8_detail as $v){
		   //内容
		   if(isset($a4[$v["lottery_kl8_id"]])){
			   $a4[$v["lottery_kl8_id"]] = $a4[$v["lottery_kl8_id"]].'#'.$v["cal"];
		   }else{
			   $a4[$v["lottery_kl8_id"]] = $v["cal"];
		   }
	   }
	   $a5 = array();
	   foreach($lottery_pk10_detail as $v){
		   //内容
		   if(isset($a5[$v["lottery_pk10_id"]])){
			   $a5[$v["lottery_pk10_id"]] = $a5[$v["lottery_pk10_id"]].'#'.$v["cal"];
		   }else{
			   $a5[$v["lottery_pk10_id"]] = $v["cal"];
		   }
	   }
	$a6 = array();
   foreach($lottery_ssc_detail as $v){
	   //内容
	   if(isset($a6[$v["lottery_ssc_id"]])){
		$a6[$v["lottery_ssc_id"]] = $a6[$v["lottery_ssc_id"]].'#'.$v["cal"];
	   }else{
		$a6[$v["lottery_ssc_id"]] = $v["cal"];
	   }
  }


	foreach($data as $k=>$v){
		foreach($class as $kk=>$vv){
			if($v["lotteryclass"] == $vv["id"]){
				$data[$k]["classname"] = $vv["name"];
			}
		}
	}


	$this->assign("caizhong",$caizhong);
	$this->assign("zhongjiang",$zhongjiang);
	$this->assign("yingli",$yingli);
	$this->assign("leixing",$leixing);
	$this->assign("touzhu",$touzhu);
	$this->assign("count",$count);
	$this->assign("wanjia",$wanjia);
	$this->assign("a1",$a1);
    $this->assign("a2",$a2);
    $this->assign("a3",$a3);
    $this->assign("a4",$a4);
    $this->assign("a5",$a5);
	$this->assign("a6",$a6);
	$this->assign("arr",$data);
	   $this->assign("p",$p);
	   $this->assign("totalpage",$totalpage);
	   $this -> assign("page",$page->show('Admin'));
	$this->assign("classs",$classs);
	$this->assign("id",$id);
	$this->display();
}
	//投注明细
	function betDetail(){
		$uid = $_SESSION['user_id'];
		$wanjia = M('Accountsinfo')->where("userid = {$uid}")->field("utype")->find();
		$id = I("id");
		$p = I("p");
		$table = I("table");
		$lotteryclass = I("lotteryclass");

		$date1 =  M("lottery_add")->where("id  = {$id} and lotteryclass = {$lotteryclass}")->select();
		$date2 =  M("lottery_11x5")->where("id  = {$id} and lotteryclass = {$lotteryclass}")->select();
		$date3 =  M("lottery_fc3d")->where("id  = {$id} and lotteryclass = {$lotteryclass}")->select();
		$date4 =  M("lottery_kl8")->where("id  = {$id} and lotteryclass = {$lotteryclass}")->select();
		$date5 =  M("lottery_pk10")->where("id  = {$id} and lotteryclass = {$lotteryclass}")->select();
		$date6 =  M("lottery_ssc")->where("id  = {$id} and lotteryclass = {$lotteryclass}")->select();
		$date = array_merge($date1,$date2,$date3,$date4,$date5,$date6);

		foreach($date as $v){
			$classid[] = $v["lotteryclass"];
		}
		$arr = implode(",",$classid);
		if($arr){
			$dat =  M("lottery_class")->where("id in($arr)")->select();
		}
		foreach($dat as $v){
			$name[] = $v["name"];
		}
		//彩种名称
		$names = implode(",",$name);

		//账户名
		$da = M('Accountsinfo')->where(" userid = '{$uid}' ")->find();
		$zhanghu = $da["accounts"];

		//列表
		if($table=='1'){
			$data = M("lottery_add_detail a")->where("lottery_add_id  = {$id}")->field("a.*,a.con_money zo_money")->select();
		}elseif($table=='2'){
			$data = M("lottery_11x5_detail")->where("lottery_11x5_id  = {$id}")->select();
		}elseif($table=='3'){
			$data = M("lottery_fc3d_detail")->where("lottery_fc3d_id  = {$id}")->select();
		}elseif($table=='4'){
			$data = M("lottery_kl8_detail")->where("lottery_kl8_id  = {$id}")->select();
		}elseif($table=='5'){
			$data = M("lottery_pk10_detail")->where("lottery_pk10_id  = {$id}")->select();
		}elseif($table=='6'){
			$data = M("lottery_ssc_detail")->where("lottery_ssc_id  = {$id}")->select();
		}
//分页 begion
		$count = count($data);
		if($count==0){
			$p = 0;
		}else{
			if(empty($p)){
				$p = 1;
			}
		}
		$data = array_slice($data,($p-1)*10,10);
		$totalpage = ceil($count/10);
		$page = $this->page($count,10);
		//end

		$count = count($data);
		$this->assign("zhanghu",$zhanghu);
		$this->assign("count",$count);
		$this->assign("names",$names);
		$this->assign("arr",$date);
		$this->assign("arr1",$data);
		$this->assign("table",$table);
		$this->assign("wanjia",$wanjia);
		$this->assign("id",$id);
		$this->assign("p",$p);
		$this->assign("totalpage",$totalpage);
		$this -> assign("page",$page->show('Admin'));
		$this->display();
	}
	//代理页面
	function agentIntro(){
		$this->display();
	}


	//追号记录
	function seekOrder(){
		$id = $_SESSION['user_id'];
		$wanjia = M('Accountsinfo')->where("userid = {$id}")->field("utype")->find();

		//搜索
		$caizhong = I("lotteryclass");
		$shijian = I("shijian");
		$leixing = I("leixing");
		$p = I("p");

		$where = array();
		$where['uid'] = $id;
		if(!empty($caizhong)){
			$where['lotteryclass'] = $caizhong;
		}
		//时间判断
		if($shijian == ''){
			$shijian = '1';
		}
		if($shijian == '1'){
			$stime = date('Y-m-d')." 00:00:00";  //今天开始时间
			$etime = date('Y-m-d')." 23:59:59";//今天结束时间
		}elseif($shijian == '2'){
			$stime = date('Y-m-d',strtotime('-1 day'))." 00:00:00";//昨天开始时间
			$etime = date('Y-m-d',strtotime('-1 day'))." 23:59:59";//昨天结束时间
		}elseif($shijian == '3'){
			$stime = date('Y-m-d',strtotime('-7 day'))." 00:00:00";//7天开始时间
			$etime = date('Y-m-d')." 23:59:59";//7天结束时间
		}
		$stimes = strtotime($stime);
		$etimes = strtotime($etime);
		$where['ctime'] = array(array('egt',$stimes),array('elt',$etimes));
		$this->assign("shijian",$shijian);

		//搜索彩票名称
		$classs = M('lottery_class')->select();
       //列表
		$data1 = M('zhui_kl8')->where($where)->select();
		$data2 = M('zhui_pk10')->where($where)->select();
		$data3 = M('zhui_ssc')->where($where)->select();
		$data4 = M('zhui_x5')->where($where)->select();
		foreach($data1 as $k=>$v){
			$data1[$k]['table'] = 1;
		}
		foreach($data2 as $k=>$v){
			$data2[$k]['table'] = 2;
		}
		foreach($data3 as $k=>$v){
			$data3[$k]['table'] = 3;
		}
		foreach($data4 as $k=>$v){
			$data4[$k]['table'] = 4;
		}


		if($leixing==""){
			$leixing='0';
		}
		//kl8 已追 begion
		$id1 = array();
		foreach($data1 as $v){
			$id1[] = $v['id'];
		}
		$ids1=implode(',',$id1);
		if($ids1){
			$data11 = M("zhui_kl8_detail")->where("zhui_kl8_id in($ids1)")->select();
		}
		foreach($data1 as $k=>$v){
			$num1 = 0;
			$mon = 0;
			foreach($data11 as $kk=>$vv){
				if($v['id']==$vv['zhui_kl8_id']){
					if(trim($vv['opencode'])){
						$num1++;
						$mon += $vv['touzhu_money'];
					}
				}
			}
			$mone = sprintf("%.2f",$mon);
			$data1[$k]['num'] = "$num1";
			$data1[$k]['money'] = "$mone";
		}

		//类型搜索 kl8 表

		foreach($data1 as $k=>$v){
			if($leixing=='0'){
				$shuzu1[] = $data1[$k];
			}elseif($leixing=='1'){
				if($v['num']=='0'){
					$shuzu1[] = $data1[$k];
				}
			}elseif($leixing=='2'){
				if($v['num'] > 0 && $v['num'] < $v['qishus']){
					$shuzu1[] = $data1[$k];
				}
			}elseif($leixing=='3'){
				if($v['num']==$v['qishus']){
					$shuzu1[] = $data1[$k];
				}
			}
		}

		//pk10已追 begion
		$id2 = array();
		foreach($data2 as $v){
			$id2[] = $v['id'];
		}
		$ids2=implode(',',$id2);
		if($ids2){
			$data22 = M("zhui_pk10_detail")->where("zhui_pk10_id in($ids2)")->select();
		}
		foreach($data2 as $k=>$v){
			$num2 = 0;
			$mon = 0;
			foreach($data22 as $kk=>$vv){
				if($v['id']==$vv['zhui_pk10_id']){
					if(trim($vv['opencode'])){
						$num2++;
						$mon += $vv['touzhu_money'];
					}
				}
			}
			$mone = sprintf("%.2f",$mon);
			$data2[$k]['num'] = "$num2";
			$data2[$k]['money'] = "$mone";
		}
		//pk10已追  end
     //类型搜索 pk10 表
		foreach($data2 as $k=>$v){
			if($leixing=='0'){
				$shuzu2[] = $data2[$k];
			}elseif($leixing=='1'){
				if($v['num']=='0'){
					$shuzu2[] = $data2[$k];
				}
			}elseif($leixing=='2'){
				if($v['num'] > 0 && $v['num'] < $v['qishus']){
					$shuzu2[] = $data2[$k];
				}
			}elseif($leixing=='3'){
				if($v['num']==$v['qishus']){
					$shuzu2[] = $data2[$k];
				}
			}
		}

        //ssc已追 begion
		$id3 = array();
		foreach($data3 as $v){
			$id3[] = $v['id'];
		}
		$ids3=implode(',',$id3);
		if($ids3){
			$data33 = M("zhui_ssc_detail")->where("zhui_ssc_id in($ids3)")->select();
		}
		foreach($data3 as $k=>$v){
			$num3 = 0;
			$mon = 0;
			foreach($data33 as $kk=>$vv){
				if($v['id']==$vv['zhui_ssc_id']){
					if(trim($vv['opencode'])){
						$num3++;
						$mon += $vv['touzhu_money'];
					}
				}
			}
			$mone = sprintf("%.2f",$mon);
			$data3[$k]['num'] = "$num3";
			$data3[$k]['money'] = "$mone";
		}
		//ssc已追  end
     //类型搜索 ssc 表
		foreach($data3 as $k=>$v){
			if($leixing=='0'){
				$shuzu3[] = $data3[$k];
			}elseif($leixing=='1'){
				if($v['num']=='0'){
					$shuzu3[] = $data3[$k];
				}
			}elseif($leixing=='2'){
				if($v['num'] > 0 && $v['num'] < $v['qishus']){
					$shuzu3[] = $data3[$k];
				}
			}elseif($leixing=='3'){
				if($v['num']==$v['qishus']){
					$shuzu3[] = $data3[$k];
				}
			}
		}

		//11X5 已追 begion
		$id4 = array();
		foreach($data4 as $v){
			$id4[] = $v['id'];
		}
		$ids4=implode(',',$id4);
		if($ids4){
			$data44 = M("zhui_x5_detail")->where("zhui_x5_id in($ids4)")->select();
		}
		foreach($data4 as $k=>$v){
			$num4 = 0;
			$mon = 0;
			foreach($data44 as $kk=>$vv){
				if($v['id']==$vv['zhui_x5_id']){
					if(trim($vv['opencode'])){
						$num4++;
						$mon += $vv['touzhu_money'];
					}
				}
			}
			$mone = sprintf("%.2f",$mon);
			$data4[$k]['num'] = "$num4";
			$data4[$k]['money'] = "$mone";
		}
		//11X5 已追 end
		//类型搜索 11X5 表
		foreach($data4 as $k=>$v){
			if($leixing=='0'){
				$shuzu4[] = $data4[$k];
			}elseif($leixing=='1'){
				if($v['num']=='0'){
					$shuzu4[] = $data4[$k];
				}
			}elseif($leixing=='2'){
				if($v['num'] > 0 && $v['num'] < $v['qishus']){
					$shuzu4[] = $data4[$k];
				}
			}elseif($leixing=='3'){
				if($v['num']==$v['qishus']){
					$shuzu4[] = $data4[$k];
				}
			}
		}
		$shuzu1 = empty($shuzu1)?array():$shuzu1;
		$shuzu2 = empty($shuzu2)?array():$shuzu2;
		$shuzu3 = empty($shuzu3)?array():$shuzu3;
		$shuzu4 = empty($shuzu4)?array():$shuzu4;
		$data = array_merge($shuzu1,$shuzu2,$shuzu3,$shuzu4);
		foreach ($data as $user) {
			$ages[] = $user['ctime'];
		}
		array_multisort($ages, SORT_DESC, $data);

		foreach($data as $v){
			$lotteryclass[] = $v["lotteryclass"]; //彩种
		}

		//彩种
		$lotteryclasss = implode(",",$lotteryclass);
		if($lotteryclasss){
			$class = M('lottery_class')->where("id in($lotteryclasss)")->select();
		}

		foreach($data as $k=>$v){
			foreach($class as $kk=>$vv){
				if($v["lotteryclass"] == $vv["id"]){
					$data[$k]["classname"] = $vv["name"];
				}
			}
		}

//分页 begion
		$count = count($data);
		if($count==0){
			$p = 0;
		}else{
			if(empty($p)){
				$p = 1;
			}
		}
		$data = array_slice($data,($p-1)*10,10);
		$totalpage = ceil($count/10);
		$page = $this->page($count,10);
		//end

		$this->assign("leixing",$leixing);
        $this->assign("caizhong",$caizhong);
		$this->assign("arr",$data);
		$this->assign("p",$p);
		$this->assign("totalpage",$totalpage);
		$this -> assign("page",$page->show('Admin'));
		$this->assign("classs",$classs);
		$this->assign("wanjia",$wanjia);
		$this->assign("id",$id);
		$this->display();
	}
	//追号记录详情
	function seekDetail(){
		$uid = $_SESSION['user_id'];
		$id = I("id");
		$wanjia = M('Accountsinfo')->where("userid = {$uid}")->field("utype")->find();
		$p = I("p");
		$table = I("table");
		$lotteryclass = I("lotteryclass");

		//列表
		$data1 = M('zhui_kl8')->where("id={$id} and lotteryclass = {$lotteryclass}")->select();
		$data2 = M('zhui_pk10')->where("id={$id} and lotteryclass = {$lotteryclass}")->select();
		$data3 = M('zhui_ssc')->where("id={$id} and lotteryclass = {$lotteryclass}")->select();
		$data4 = M('zhui_x5')->where("id={$id} and lotteryclass = {$lotteryclass}")->select();
		//kl8 已追 begion
		$id1 = array();
		foreach($data1 as $v){
			$id1[] = $v['id'];
		}
		$ids1=implode(',',$id1);
		if($ids1){
			$data11 = M("zhui_kl8_detail")->where("zhui_kl8_id in($ids1)")->select();
		}
		foreach($data1 as $k=>$v){
			$num1 = 0;
			$mon = 0;
			foreach($data11 as $kk=>$vv){
				if($v['id']==$vv['zhui_kl8_id']){
					if(trim($vv['opencode'])){
						$num1++;
						$mon += $vv['touzhu_money'];
					}
				}
			}
			$mone = sprintf("%.2f",$mon);
			$data1[$k]['num'] = "$num1";
			$data1[$k]['money'] = "$mone";
		}

		//pk10已追 begion
		$id2 = array();
		foreach($data2 as $v){
			$id2[] = $v['id'];
		}
		$ids2=implode(',',$id2);
		if($ids2){
			$data22 = M("zhui_pk10_detail")->where("zhui_pk10_id in($ids2)")->select();
		}
		foreach($data2 as $k=>$v){
			$num2 = 0;
			$mon = 0;
			foreach($data22 as $kk=>$vv){
				if($v['id']==$vv['zhui_pk10_id']){
					if(trim($vv['opencode'])){
						$num2++;
						$mon += $vv['touzhu_money'];
					}
				}
			}
			$mone = sprintf("%.2f",$mon);
			$data2[$k]['num'] = "$num2";
			$data2[$k]['money'] = "$mone";
		}
		//pk10已追  end


		//ssc已追 begion
		$id3 = array();
		foreach($data3 as $v){
			$id3[] = $v['id'];
		}
		$ids3=implode(',',$id3);
		if($ids3){
			$data33 = M("zhui_ssc_detail")->where("zhui_ssc_id in($ids3)")->select();
		}
		foreach($data3 as $k=>$v){
			$num3 = 0;
			$mon = 0;
			foreach($data33 as $kk=>$vv){
				if($v['id']==$vv['zhui_ssc_id']){
					if(trim($vv['opencode'])){
						$num3++;
						$mon += $vv['touzhu_money'];
					}
				}
			}
			$mone = sprintf("%.2f",$mon);
			$data3[$k]['num'] = "$num3";
			$data3[$k]['money'] = "$mone";
		}
		//ssc已追  end

		//11X5 已追 begion
		$id4 = array();
		foreach($data4 as $v){
			$id4[] = $v['id'];
		}
		$ids4=implode(',',$id4);
		if($ids4){
			$data44 = M("zhui_x5_detail")->where("zhui_x5_id in($ids4)")->select();
		}
		foreach($data4 as $k=>$v){
			$num4 = 0;
			$mon = 0;
			foreach($data44 as $kk=>$vv){
				if($v['id']==$vv['zhui_x5_id']){
					if(trim($vv['opencode'])){
						$num4++;
						$mon += $vv['touzhu_money'];
					}
				}
			}
			$mone = sprintf("%.2f",$mon);
			$data4[$k]['num'] = "$num4";
			$data4[$k]['money'] = "$mone";
		}
		//11X5 已追 end
		$data = array_merge($data1,$data2,$data3,$data4);
		foreach($data as $v){
			$classid[] = $v["lotteryclass"];
		}
		$arr = implode(",",$classid);
		if($arr){
			$dat =  M("lottery_class")->where("id in($arr)")->select();
		}
		foreach($dat as $v){
			$name[] = $v["name"];
		}
		//彩种名称
		$names = implode(",",$name);


		//追号方案

		//列表
		if($table=='1'){
			$date = M("zhui_kl8_detail")->where("zhui_kl8_id  = {$id}")->select();
		}elseif($table=='2'){
			$date = M("zhui_pk10_detail")->where("zhui_pk10_id  = {$id}")->select();
		}elseif($table=='3'){
			$date = M("zhui_ssc_detail")->where("zhui_ssc_id  = {$id}")->select();
		}elseif($table=='4'){
			$date = M("zhui_x5_detail")->where("zhui_x5_id  = {$id}")->select();
		}

		//分页 begion
		$count = count($data);
		if($count==0){
			$p = 0;
		}else{
			if(empty($p)){
				$p = 1;
			}
		}
		array_slice($data,($p-1)*10,10);
		$totalpage = ceil($count/10);
		$page = $this->page($count,10);
		//end
		$this->assign("lotteryclass",$lotteryclass);
		$this->assign("table",$table);
		$this->assign("arr1",$date);
		$this->assign("arr",$data);
		$this->assign("names",$names);
		$this->assign("id",$id);
		$this->assign("p",$p);
		$this->assign("totalpage",$totalpage);
		$this -> assign("page",$page->show('Admin'));
		$this->assign("wanjia",$wanjia);
		$this->assign("id",$id);
		$this->display();
	}
	function betDetail2(){
		$uid = $_SESSION['user_id'];
		$wanjia = M('Accountsinfo')->where("userid = {$uid}")->field("utype")->find();
		$p = I("p");
		$id = I("id");
		$table = I("table");
		$lotteryclass = I("lotteryclass");

		//列表
		$data1 = M('zhui_kl8')->where("lotteryclass = {$lotteryclass}")->select();
		$data2 = M('zhui_pk10')->where("lotteryclass = {$lotteryclass}")->select();
		$data3 = M('zhui_ssc')->where("lotteryclass = {$lotteryclass}")->select();
		$data4 = M('zhui_x5')->where("lotteryclass = {$lotteryclass}")->select();
		$data = array_merge($data1,$data2,$data3,$data4);

		foreach($data as $v){
			$classid[] = $v["lotteryclass"];
		}
		$arr = implode(",",$classid);

		if($arr){
			$dat =  M("lottery_class")->where("id in($arr)")->select();
		}

		foreach($dat as $v){
			$name[] = $v["name"];
		}
		//彩种名称
		$names = implode(",",$name);


		//追号方案

		//列表
		if($table=='1'){
			$date = M("zhui_kl8_detail")->where("id  = {$id}")->select();
		}elseif($table=='2'){
			$date = M("zhui_pk10_detail")->where("id  = {$id}")->select();
		}elseif($table=='3'){
			$date = M("zhui_ssc_detail")->where("id  = {$id}")->select();
		}elseif($table=='4'){
			$date = M("zhui_x5_detail")->where("id  = {$id}")->select();
		}
		if($table=='1'){
			foreach($date as $v){
				$zhui_id[] = $v['zhui_kl8_id'];
				$zo[] = $v['zhong_money'];
			}
		}elseif($table=='2'){
			foreach($date as $v){
				$zhui_id[] = $v['zhui_pk10_id'];
				$zo[] = $v['zhong_money'];
			}
		}elseif($table=='3'){
			foreach($date as $v){
				$zhui_id[] = $v['zhui_ssc_id'];
				$zo[] = $v['zhong_money'];
			}
		}elseif($table=='4'){
			foreach($date as $v){
				$zhui_id[] = $v['zhui_x5_id'];
				$zo[] = $v['zhong_money'];
			}
		}
		$zhui_ids = implode(",",$zhui_id);
		$zo_money = implode(",",$zo);
		$mone = sprintf("%.2f",$zo_money);


		if($table=='1'){
			$date2 = M("zhui_kl8")->where("id  = {$zhui_ids}")->select();
		}elseif($table=='2'){
			$date2 = M("zhui_pk10")->where("id  = {$zhui_ids}")->select();
		}elseif($table=='3'){
			$date2 = M("zhui_ssc")->where("id  = {$zhui_ids}")->select();
		}elseif($table=='4'){
			$date2 = M("zhui_x5")->where("id  = {$zhui_ids}")->select();
		}
		//投注时间
        foreach($date2 as $v){
			$ctime[] = $v['ctime'];
		}
		$ctimes = implode(",",$ctime);



		//分页 begion
		$count = count($data);
		if($count==0){
			$p = 0;
		}else{
			if(empty($p)){
				$p = 1;
			}
		}
		array_slice($data,($p-1)*10,10);
		$totalpage = ceil($count/10);
		$page = $this->page($count,10);
		//end

		$this->assign("mone",$mone);
		$this->assign("ctimes",$ctimes);
		$this->assign("table",$table);
		$this->assign("arr2",$date2);
		$this->assign("arr1",$date);
		$this->assign("arr",$data);
		$this->assign("names",$names);
		$this->assign("id",$id);
		$this->assign("p",$p);
		$this->assign("totalpage",$totalpage);
		$this -> assign("page",$page->show('Admin'));
		$this->assign("wanjia",$wanjia);
		$this->assign("id",$id);
		$this->display();
	}


	 //代理中心 下级开户
	 function manageInvite(){
		if(IS_POST){
			$uid = $_SESSION['user_id'];
			$data["uid"] = $uid;
			$data["type"] = I("type");
			$data["ssc"] = I("ssc");
			$data["k3"] = I("k3");
			$data["x11_5"] = I("x11_5");
			$data["fc3d"] = I("f3d");
			$data["pl3_5"] = I("pl_35");
			$data["kl8"] = I("kl8");
			$data["pk10"] = I("pk10");
			$data["ctime"] = time();
			$data["code"] = mt_rand(10000000,99999999);
			$data["link"] = $_SERVER['HTTP_HOST']."/Index/register?id=".$data["code"];
            M("agent")->add($data);
			echo 1;
		}else{
			$uid = $_SESSION['user_id'];

			if($uid){
				$data = M('Accountsinfo')
						->where("userid = '{$uid}'")
						->field("yq_code")
						->find();
			}

			if($data['yq_code']){
				$date = M("agent")->where("code=".$data['yq_code'])->find();
			}

			$this->assign("arr",$date);
			$this->assign("uid",$uid);
			$this->display();
		}
	}
	public function re_k3(){
		$uid = $_SESSION['user_id'];
		$da = M('Accountsinfo')->where("userid = '{$uid}' ")->field("yq_code")->find();
		if($da['yq_code']){
			$lv = M("agent")->where("code = '{$da['yq_code']}'")->field("k3")->find();
		}
		$k3 = array();
		$k31 = array();
		$n_k3 = array();
		$n_k31 = array();
		$res = M("rebate_k3")->find();
		$k3[] = trim($lv['k3']);
		$k31[] = trim($lv['k3']);
		for($i = floor(trim($lv['k3']));$i>=0;$i--){
			if(!in_array($i,$k3)){
				$k3[] = $i.".0";
			}
		}
		foreach($k3 as $kk=>$vv){
			$n_k3[$vv] = array(
				($vv-0)*0.01+$res['daxiao'],
				($vv-0)*2.16+$res['he3'],
				($vv-0)*0.72+$res['he4'],
				($vv-0)*0.36+$res['he5'],
				($vv-0)*0.21+$res['he6'],
				($vv-0)*0.14+$res['he7'],
				($vv-0)*0.10+$res['he8'],
				($vv-0)*0.09+$res['he9'],
				($vv-0)*0.08+$res['he10'],
				($vv-0)*0.36+$res['t3tx'],
				($vv-0)*2.16+$res['t3dx'],
				($vv-0)*0.36+$res['bt3'],
				($vv-0)*0.09+$res['t3lh'],
				($vv-0)*0.15+$res['ertfx'],
				($vv-0)*0.72+$res['ertdx'],
				($vv-0)*0.07+$res['bt2'],
			);
		}
		for($i1 = (int)(trim($lv['k3']));$i1>0.1;$i1-=0.1){
			if(!in_array($i1,$k31)){
				if(strstr($i1,".")){
					$k31[] = (string)$i1;
				}else{
					$k31[] = (string)$i1.".0";
				}
			}
		}
		$k31[] = '0.0';
		foreach($k31 as $kk1=>$vv1){
			$n_k31[$vv1] = array(
				($vv1-0)*0.01+$res['daxiao'],
				($vv1-0)*2.16+$res['he3'],
				($vv1-0)*0.72+$res['he4'],
				($vv1-0)*0.36+$res['he5'],
				($vv1-0)*0.21+$res['he6'],
				($vv1-0)*0.14+$res['he7'],
				($vv1-0)*0.10+$res['he8'],
				($vv1-0)*0.09+$res['he9'],
				($vv1-0)*0.08+$res['he10'],
				($vv1-0)*0.36+$res['t3tx'],
				($vv1-0)*2.16+$res['t3dx'],
				($vv1-0)*0.36+$res['bt3'],
				($vv1-0)*0.09+$res['t3lh'],
				($vv1-0)*0.15+$res['ertfx'],
				($vv1-0)*0.72+$res['ertdx'],
				($vv1-0)*0.07+$res['bt2'],
			);
		}
		$this->assign("n_k3",$n_k3);
		$this->assign("n_k31",$n_k31);
		$this->display("rebateDes_K3");
	}
	public function re_ssc(){
		$uid = $_SESSION['user_id'];
		$da = M('Accountsinfo')->where("userid = '{$uid}' ")->field("yq_code")->find();
		if($da['yq_code']){
			$lv = M("agent")->where("code = '{$da['yq_code']}'")->field("ssc")->find();
		}

		$ssc = array();
		$ssc1 = array();
		$n_ssc = array();
		$n_ssc1 = array();
		$res = M("rebate_ssc")->find();
		$ssc[] = trim($lv['ssc']);
		$ssc1[] = trim($lv['ssc']);
		for($i = floor(trim($lv['ssc']));$i>=0;$i--){
			if(!in_array($i,$ssc)){
				$ssc[] = $i.".0";
			}
		}
		foreach($ssc as $kk=>$vv){
			$n_ssc[$vv] = array(
				($vv-0)*0.08+$res['dx2xing'],
				($vv-0)*0.16+$res['dx3xing'],
				($vv-0)*0.2+$res['yxingfs'],
				($vv-0)*2+$res['exingzxfs'],
				($vv-0)*2+$res['exingzxds'],
				($vv-0)*2+$res['exingzxhz'],
				($vv-0)*2+$res['exingkadu'],
				($vv-0)*1+$res['exingzufs'],
				($vv-0)*1+$res['exingzuds'],
				($vv-0)*1+$res['exingzuhz'],
				($vv-0)*1+$res['exingzubd'],
				($vv-0)*20+$res['sxingfs'],
				($vv-0)*20+$res['sxingds'],
				($vv-0)*20+$res['sxingzhz'],
				($vv-0)*20+$res['sxingkudu'],
				($vv-0)*3.33+$res['sxingzuhe'],
				($vv-0)*6.66+$res['sxingzu3'],
				($vv-0)*3.33+$res['sxingzu6'],
				($vv-0)*3.33+$res['sxinghunhe'],
				($vv-0)*3.33+$res['sxingzubd'],
				($vv-0)*6.66+$res['sxingzu3ds'],
				($vv-0)*3.33+$res['sxingzu6ds'],
				($vv-0)*0.07+$res['sxingyima'],
				($vv-0)*0.37+$res['sxingerma'],
				($vv-0)*2000+$res['fxingfs'],
				($vv-0)*2000+$res['fxingds'],
				($vv-0)*3.33+$res['fxingzu24'],
				($vv-0)*16.66+$res['fxingzu12'],
				($vv-0)*33.33+$res['fxingzu6'],
				($vv-0)*50+$res['fxingzu4'],
				($vv-0)*0.06+$res['fxingyima'],
				($vv-0)*0.2+$res['fxingerma'],
				($vv-0)*2000+$res['wxingfs'],
				($vv-0)*2000+$res['wxingds'],
				($vv-0)*16.66+$res['wxingzu120'],
				($vv-0)*33.33+$res['wxingzu60'],
				($vv-0)*66.66+$res['wxingzu30'],
				($vv-0)*100+$res['wxingzu20'],
				($vv-0)*200+$res['wxingzu10'],
				($vv-0)*400+$res['wxingzu5'],
				($vv-0)*0.05+$res['wxingyima'],
				($vv-0)*0.14+$res['wxingerma'],
				($vv-0)*0.46+$res['wxingsanma'],
				($vv-0)*0.05+$res['wxingyifan'],
				($vv-0)*0.25+$res['wxinghaos'],
				($vv-0)*2.33+$res['wxingbaox'],
				($vv-0)*43.48+$res['wxingsiji']
			);
		}
		for($i1 = (int)(trim($lv['ssc']));$i1>0.1;$i1-=0.1){
			if(!in_array($i1,$ssc1)){
				if(strstr($i1,".")){
					$ssc1[] = (string)$i1;
				}else{
					$ssc1[] = (string)$i1.".0";
				}
			}
		}
		$ssc1[] = '0.0';
		foreach($ssc1 as $kk1=>$vv1){
			$n_ssc1[$vv1] = array(
				($vv1-0)*0.08+$res['dx2xing'],
				($vv1-0)*0.16+$res['dx3xing'],
				($vv1-0)*0.2+$res['yxingfs'],
				($vv1-0)*2+$res['exingzxfs'],
				($vv1-0)*2+$res['exingzxds'],
				($vv1-0)*2+$res['exingzxhz'],
				($vv1-0)*2+$res['exingkadu'],
				($vv1-0)*1+$res['exingzufs'],
				($vv1-0)*1+$res['exingzuds'],
				($vv1-0)*1+$res['exingzuhz'],
				($vv1-0)*1+$res['exingzubd'],
				($vv1-0)*20+$res['sxingfs'],
				($vv1-0)*20+$res['sxingds'],
				($vv1-0)*20+$res['sxingzhz'],
				($vv1-0)*20+$res['sxingkudu'],
				($vv1-0)*3.33+$res['sxingzuhe'],
				($vv1-0)*6.66+$res['sxingzu3'],
				($vv1-0)*3.33+$res['sxingzu6'],
				($vv1-0)*3.33+$res['sxinghunhe'],
				($vv1-0)*3.33+$res['sxingzubd'],
				($vv1-0)*6.66+$res['sxingzu3ds'],
				($vv1-0)*3.33+$res['sxingzu6ds'],
				($vv1-0)*0.07+$res['sxingyima'],
				($vv1-0)*0.37+$res['sxingerma'],
				($vv1-0)*2000+$res['fxingfs'],
				($vv1-0)*2000+$res['fxingds'],
				($vv1-0)*3.33+$res['fxingzu24'],
				($vv1-0)*16.66+$res['fxingzu12'],
				($vv1-0)*33.33+$res['fxingzu6'],
				($vv1-0)*50+$res['fxingzu4'],
				($vv1-0)*0.06+$res['fxingyima'],
				($vv1-0)*0.2+$res['fxingerma'],
				($vv1-0)*2000+$res['wxingfs'],
				($vv1-0)*2000+$res['wxingds'],
				($vv1-0)*16.66+$res['wxingzu120'],
				($vv1-0)*33.33+$res['wxingzu60'],
				($vv1-0)*66.66+$res['wxingzu30'],
				($vv1-0)*100+$res['wxingzu20'],
				($vv1-0)*200+$res['wxingzu10'],
				($vv1-0)*400+$res['wxingzu5'],
				($vv1-0)*0.05+$res['wxingyima'],
				($vv1-0)*0.14+$res['wxingerma'],
				($vv1-0)*0.46+$res['wxingsanma'],
				($vv1-0)*0.05+$res['wxingyifan'],
				($vv1-0)*0.25+$res['wxinghaos'],
				($vv1-0)*2.33+$res['wxingbaox'],
				($vv1-0)*43.48+$res['wxingsiji']
			);
		}
		$this->assign("n_ssc",$n_ssc);
		$this->assign("n_ssc1",$n_ssc1);
		$this->display("rebateDes_ssc");
	}
	public function re_syx5(){
		$uid = $_SESSION['user_id'];
		$da = M('Accountsinfo')->where("userid = '{$uid}' ")->field("yq_code")->find();
		if($da['yq_code']){
			$lv = M("agent")->where("code = '{$da['yq_code']}'")->field("x11_5")->find();
		}
		$x11_5 = array();
		$x11_51 = array();
		$n_x11_5 = array();
		$n_x11_51 = array();
		$res = M("rebate_syx5")->find();
		$x11_5[] = trim($lv['x11_5']);
		$x11_51[] = trim($lv['x11_5']);
		for($i = floor(trim($lv['x11_5']));$i>=0;$i--){
			if(!in_array($i,$x11_5)){
				$x11_5[] = $i.".0";
			}
		}
		foreach($x11_5 as $kk=>$vv){
			$n_x11_5[$vv] = array(
				($vv-0)*19.80+$res['smq3zhifs'],
				($vv-0)*0.16+$res['smq3zhids'],
				($vv-0)*3.30+$res['smq3zufs'],
				($vv-0)*3.30+$res['smq3zuds'],
				($vv-0)*3.30+$res['smq3zudt'],
				($vv-0)*2.20+$res['emq2zhifs'],
				($vv-0)*2.20+$res['emq2zhids'],
				($vv-0)*1.10+$res['emq2zufs'],
				($vv-0)*1.10+$res['emq2zuds'],
				($vv-0)*1.10+$res['emq2zudt'],
				($vv-0)*1.07+$res['q3ymbdw'],
				($vv-0)*0.22+$res['dwdfs'],
				($vv-0)*1.54+$res['d5s0'],
				($vv-0)*0.13+$res['d4s1'],
				($vv-0)*0.55+$res['d3s2'],
				($vv-0)*0.06+$res['d2s3'],
				($vv-0)*0.31+$res['d1s4'],
				($vv-0)*9.24+$res['d0s5'],
				($vv-0)*0.33+$res['mid03'],
				($vv-0)*0.14+$res['mid04'],
				($vv-0)*0.10+$res['mid05'],
				($vv-0)*0.09+$res['mid06'],
				($vv-0)*0.04+$res['rxfs1z1'],
				($vv-0)*0.11+$res['rxfs2z2'],
				($vv-0)*0.33+$res['rxfs3z3'],
				($vv-0)*0.04+$res['rxds1z1'],
				($vv-0)*1.32+$res['rxfs4z4'],
				($vv-0)*9.24+$res['rxfs5z5'],
				($vv-0)*1.54+$res['rxfs6z5'],
				($vv-0)*0.44+$res['rxfs7z5'],
				($vv-0)*0.16+$res['rxfs8z5'],
				($vv-0)*0.11+$res['rxds2z2'],
				($vv-0)*0.32+$res['rxds3z3'],
				($vv-0)*1.32+$res['rxds4z4'],
				($vv-0)*9.24+$res['rxds5z5'],
				($vv-0)*1.53+$res['rxds6z5'],
				($vv-0)*0.44+$res['rxds7z5'],
				($vv-0)*0.16+$res['rxds8z5'],
				($vv-0)*0.11+$res['rxdt2z2'],
				($vv-0)*0.33+$res['rxdt3z3'],
				($vv-0)*1.32+$res['rxdt4z4'],
				($vv-0)*9.24+$res['rxdt5z5'],
				($vv-0)*1.53+$res['rxdt6z5'],
				($vv-0)*0.44+$res['rxdt7z5'],
				($vv-0)*0.16+$res['rxdt8z5']
			);
		}
		for($i1 = (int)(trim($lv['x11_5']));$i1>0.1;$i1-=0.1){
			if(!in_array($i1,$x11_51)){
				if(strstr($i1,".")){
					$x11_51[] = (string)$i1;
				}else{
					$x11_51[] = (string)$i1.".0";
				}
			}
		}
		$x11_51[] = '0.0';
		foreach($x11_51 as $kk1=>$vv1){
			$n_x11_51[$vv1] = array(
				($vv1-0)*19.80+$res['smq3zhifs'],
				($vv1-0)*0.16+$res['smq3zhids'],
				($vv1-0)*3.30+$res['smq3zufs'],
				($vv1-0)*3.30+$res['smq3zuds'],
				($vv1-0)*3.30+$res['smq3zudt'],
				($vv1-0)*2.20+$res['emq2zhifs'],
				($vv1-0)*2.20+$res['emq2zhids'],
				($vv1-0)*1.10+$res['emq2zufs'],
				($vv1-0)*1.10+$res['emq2zuds'],
				($vv1-0)*1.10+$res['emq2zudt'],
				($vv1-0)*1.07+$res['q3ymbdw'],
				($vv1-0)*0.22+$res['dwdfs'],
				($vv1-0)*1.54+$res['d5s0'],
				($vv1-0)*0.13+$res['d4s1'],
				($vv1-0)*0.55+$res['d3s2'],
				($vv1-0)*0.06+$res['d2s3'],
				($vv1-0)*0.31+$res['d1s4'],
				($vv1-0)*9.24+$res['d0s5'],
				($vv1-0)*0.33+$res['mid03'],
				($vv1-0)*0.14+$res['mid04'],
				($vv1-0)*0.10+$res['mid05'],
				($vv1-0)*0.09+$res['mid06'],
				($vv1-0)*0.04+$res['rxfs1z1'],
				($vv1-0)*0.11+$res['rxfs2z2'],
				($vv1-0)*0.33+$res['rxfs3z3'],
				($vv1-0)*0.04+$res['rxds1z1'],
				($vv1-0)*1.32+$res['rxfs4z4'],
				($vv1-0)*9.24+$res['rxfs5z5'],
				($vv1-0)*1.54+$res['rxfs6z5'],
				($vv1-0)*0.44+$res['rxfs7z5'],
				($vv1-0)*0.16+$res['rxfs8z5'],
				($vv1-0)*0.11+$res['rxds2z2'],
				($vv1-0)*0.32+$res['rxds3z3'],
				($vv1-0)*1.32+$res['rxds4z4'],
				($vv1-0)*9.24+$res['rxds5z5'],
				($vv1-0)*1.53+$res['rxds6z5'],
				($vv1-0)*0.44+$res['rxds7z5'],
				($vv1-0)*0.16+$res['rxds8z5'],
				($vv1-0)*0.11+$res['rxdt2z2'],
				($vv1-0)*0.33+$res['rxdt3z3'],
				($vv1-0)*1.32+$res['rxdt4z4'],
				($vv1-0)*9.24+$res['rxdt5z5'],
				($vv1-0)*1.53+$res['rxdt6z5'],
				($vv1-0)*0.44+$res['rxdt7z5'],
				($vv1-0)*0.16+$res['rxdt8z5']
			);
		}
		$this->assign("n_x11_5",$n_x11_5);
		$this->assign("n_x11_51",$n_x11_51);
		$this->display("rebateDes_SYX5");
	}
	public function re_fc3d(){
		$uid = $_SESSION['user_id'];
		$da = M('Accountsinfo')->where("userid = '{$uid}' ")->field("yq_code")->find();
		if($da['yq_code']){
			$lv = M("agent")->where("code = '{$da['yq_code']}'")->field("fc3d")->find();
		}
		$fc3d = array();
		$fc3d1 = array();
		$n_fc3d = array();
		$n_fc3d1 = array();
		$res = M("rebate_fc3d")->find();
		$fc3d[] = trim($lv['fc3d']);
		$fc3d1[] = trim($lv['fc3d']);
		for($i = floor(trim($lv['fc3d']));$i>=0;$i--){
			if(!in_array($i,$fc3d)){
				$fc3d[] = $i.".0";
			}
		}
		foreach($fc3d as $kk=>$vv){
			$n_fc3d[$vv] = array(
				($vv-0)*0.08+$res['daxiao'],
				($vv-0)*0.20+$res['yxfs'],
				($vv-0)*2.00+$res['hou2zhix'],
				($vv-0)*1.00+$res['hou2zux'],
				($vv-0)*2.00+$res['qian2zhix'],
				($vv-0)*1.00+$res['qian2zux'],
				($vv-0)*20.00+$res['sxingzhix'],
				($vv-0)*6.66+$res['sxingzux'],
				($vv-0)*6.66+$res['sxingzu3'],
				($vv-0)*3.33+$res['sxingzu6'],
				($vv-0)*6.66+$res['sxinghunhe'],
				($vv-0)*6.66+$res['sxingbd'],
				($vv-0)*6.66+$res['sxingzu3ds'],
				($vv-0)*3.33+$res['sxingzu6ds'],
				($vv-0)*0.07+$res['sxingyima'],
				($vv-0)*0.37+$res['sxingerma']
			);
		}
		for($i1 = (int)(trim($lv['fc3d']));$i1>0.1;$i1-=0.1){
			if(!in_array($i1,$fc3d1)){
				if(strstr($i1,".")){
					$fc3d1[] = (string)$i1;
				}else{
					$fc3d1[] = (string)$i1.".0";
				}
			}
		}
		$fc3d1[] = '0.0';
		foreach($fc3d1 as $kk1=>$vv1){
			$n_fc3d1[$vv1] = array(
				($vv1-0)*0.08+$res['daxiao'],
				($vv1-0)*0.20+$res['yxfs'],
				($vv1-0)*2.00+$res['hou2zhix'],
				($vv1-0)*1.00+$res['hou2zux'],
				($vv1-0)*2.00+$res['qian2zhix'],
				($vv1-0)*1.00+$res['qian2zux'],
				($vv1-0)*20.00+$res['sxingzhix'],
				($vv1-0)*6.66+$res['sxingzux'],
				($vv1-0)*6.66+$res['sxingzu3'],
				($vv1-0)*3.33+$res['sxingzu6'],
				($vv1-0)*6.66+$res['sxinghunhe'],
				($vv1-0)*6.66+$res['sxingbd'],
				($vv1-0)*6.66+$res['sxingzu3ds'],
				($vv1-0)*3.33+$res['sxingzu6ds'],
				($vv1-0)*0.07+$res['sxingyima'],
				($vv1-0)*0.37+$res['sxingerma']
			);
		}
		$this->assign("n_fc3d",$n_fc3d);
		$this->assign("n_fc3d1",$n_fc3d1);
		$this->display("rebateDes_FC3D");
	}
	public function re_pl3(){
		$uid = $_SESSION['user_id'];
		$da = M('Accountsinfo')->where("userid = '{$uid}' ")->field("yq_code")->find();
		if($da['yq_code']){
			$lv = M("agent")->where("code = '{$da['yq_code']}'")->field("pl3_5")->find();
		}

		$pl3 = array();
		$pl31 = array();
		$n_pl3 = array();
		$n_pl31 = array();
		$res = M("rebate_pl3")->find();
		$pl3[] = trim($lv['pl3_5']);
		$pl31[] = trim($lv['pl3_5']);
		for($i = floor(trim($lv['pl3_5']));$i>=0;$i--){
			if(!in_array($i,$pl3)){
				$pl3[] = $i.".0";
			}
		}
		foreach($pl3 as $kk=>$vv){
			$n_pl3[$vv] = array(
				($vv-0)*0.08+$res['daxiao'],
				($vv-0)*0.20+$res['yxfs'],
				($vv-0)*2.00+$res['hou2zhix'],
				($vv-0)*1.00+$res['hou2zux'],
				($vv-0)*2.00+$res['qian2zhix'],
				($vv-0)*1.00+$res['qian2zux'],
				($vv-0)*20.00+$res['sxingzhix'],
				($vv-0)*6.66+$res['sxingzux'],
				($vv-0)*6.66+$res['sxingzu3'],
				($vv-0)*3.33+$res['sxingzu6'],
				($vv-0)*6.66+$res['sxinghunhe'],
				($vv-0)*6.66+$res['sxingbd'],
				($vv-0)*6.66+$res['sxingzu3ds'],
				($vv-0)*3.33+$res['sxingzu6ds'],
				($vv-0)*0.07+$res['sxingyima'],
				($vv-0)*0.37+$res['sxingerma']
			);
		}
		for($i1 = (int)(trim($lv['pl3_5']));$i1>0.1;$i1-=0.1){
			if(!in_array($i1,$pl31)){
				if(strstr($i1,".")){
					$pl31[] = (string)$i1;
				}else{
					$pl31[] = (string)$i1.".0";
				}
			}
		}
		$pl31[] = '0.0';
		foreach($pl31 as $kk1=>$vv1){
			$n_pl31[$vv1] = array(
				($vv1-0)*0.08+$res['daxiao'],
				($vv1-0)*0.20+$res['yxfs'],
				($vv1-0)*2.00+$res['hou2zhix'],
				($vv1-0)*1.00+$res['hou2zux'],
				($vv1-0)*2.00+$res['qian2zhix'],
				($vv1-0)*1.00+$res['qian2zux'],
				($vv1-0)*20.00+$res['sxingzhix'],
				($vv1-0)*6.66+$res['sxingzux'],
				($vv1-0)*6.66+$res['sxingzu3'],
				($vv1-0)*3.33+$res['sxingzu6'],
				($vv1-0)*6.66+$res['sxinghunhe'],
				($vv1-0)*6.66+$res['sxingbd'],
				($vv1-0)*6.66+$res['sxingzu3ds'],
				($vv1-0)*3.33+$res['sxingzu6ds'],
				($vv1-0)*0.07+$res['sxingyima'],
				($vv1-0)*0.37+$res['sxingerma']
			);
		}
		$this->assign("n_pl3",$n_pl3);
		$this->assign("n_pl31",$n_pl31);
		$this->display("rebateDes_PL3");
	}
	public function re_kl8(){
		$uid = $_SESSION['user_id'];
		$da = M('Accountsinfo')->where("userid = '{$uid}' ")->field("yq_code")->find();
		if($da['yq_code']){
			$lv = M("agent")->where("code = '{$da['yq_code']}'")->field("kl8")->find();
		}

		$kl8 = array();
		$kl81 = array();
		$n_kl8 = array();
		$n_kl81 = array();
		$res = M("rebate_kl8")->find();
		$kl8[] = trim($lv['kl8']);
		$kl81[] = trim($lv['kl8']);
		for($i = floor(trim($lv['kl8']));$i>=0;$i--){
			if(!in_array($i,$kl8)){
				$kl8[] = $i.".0";
			}
		}
		foreach($kl8 as $kk=>$vv){
			$n_kl8[$vv] = array(
				($vv-0)*0.08+$res['rx1'],
				($vv-0)*0.33+$res['rx2'],
				($vv-0)*1.44+$res['rx3mid3'],
				($vv-0)*0.14+$res['rx3mid2'],
				($vv-0)*6.53+$res['rx4mid4'],
				($vv-0)*0.46+$res['rx4mid3'],
				($vv-0)*0.09+$res['rx4mid2'],
				($vv-0)*31.01+$res['rx5mid5'],
				($vv-0)*1.65+$res['rx5mid4'],
				($vv-0)*0.24+$res['rx5mid3'],
				($vv-0)*155.06+$res['rx6mid6'],
				($vv-0)*6.46+$res['rx6mid5'],
				($vv-0)*0.70+$res['rx6mid4'],
				($vv-0)*0.15+$res['rx6mid3'],
				($vv-0)*819.58+$res['rx7mid7'],
				($vv-0)*27.32+$res['rx7mid6'],
				($vv-0)*2.32+$res['rx7mid5'],
				($vv-0)*0.38+$res['rx7mid4'],
				($vv-0)*0.17+$res['rx7mid0'],
				($vv-0)*0.05+$res['qwsx'],
				($vv-0)*0.10+$res['qwsxhe'],
				($vv-0)*0.05+$res['qwjo'],
				($vv-0)*0.10+$res['qwjohe'],
				($vv-0)*0.08+$res['qwhezhi']
			);
		}
		for($i1 = (int)(trim($lv['kl8']));$i1>0.1;$i1-=0.1){
			if(!in_array($i1,$kl81)){
				if(strstr($i1,".")){
					$kl81[] = (string)$i1;
				}else{
					$kl81[] = (string)$i1.".0";
				}
			}
		}
		$kl81[] = '0.0';
		foreach($kl81 as $kk1=>$vv1){
			$n_kl81[$vv1] = array(
				($vv1-0)*0.08+$res['rx1'],
				($vv1-0)*0.33+$res['rx2'],
				($vv1-0)*1.44+$res['rx3mid3'],
				($vv1-0)*0.14+$res['rx3mid2'],
				($vv1-0)*6.53+$res['rx4mid4'],
				($vv1-0)*0.46+$res['rx4mid3'],
				($vv1-0)*0.09+$res['rx4mid2'],
				($vv1-0)*31.01+$res['rx5mid5'],
				($vv1-0)*1.65+$res['rx5mid4'],
				($vv1-0)*0.24+$res['rx5mid3'],
				($vv1-0)*155.06+$res['rx6mid6'],
				($vv1-0)*6.46+$res['rx6mid5'],
				($vv1-0)*0.70+$res['rx6mid4'],
				($vv1-0)*0.15+$res['rx6mid3'],
				($vv1-0)*819.58+$res['rx7mid7'],
				($vv1-0)*27.32+$res['rx7mid6'],
				($vv1-0)*2.32+$res['rx7mid5'],
				($vv1-0)*0.38+$res['rx7mid4'],
				($vv1-0)*0.17+$res['rx7mid0'],
				($vv1-0)*0.05+$res['qwsx'],
				($vv1-0)*0.10+$res['qwsxhe'],
				($vv1-0)*0.05+$res['qwjo'],
				($vv1-0)*0.10+$res['qwjohe'],
				($vv1-0)*0.08+$res['qwhezhi']
			);
		}
		$this->assign("n_kl8",$n_kl8);
		$this->assign("n_kl81",$n_kl81);
		$this->display("rebateDes_KL8");
	}
	public function re_pk10(){
		$uid = $_SESSION['user_id'];
		$da = M('Accountsinfo')->where("userid = '{$uid}' ")->field("yq_code")->find();
		if($da['yq_code']){
			$lv = M("agent")->where("code = '{$da['yq_code']}'")->field("pk10")->find();
		}

		$pk10 = array();
		$pk101 = array();
		$n_pk10 = array();
		$n_pk101 = array();
		$res = M("rebate_pk10")->find();
		$pk10[] = trim($lv['pk10']);
		$pk101[] = trim($lv['pk10']);
		for($i = floor(trim($lv['pk10']));$i>=0;$i--){
			if(!in_array($i,$pk10)){
				$pk10[] = $i.".0";
			}
		}
		foreach($pk10 as $kk=>$vv){
			$n_pk10[$vv] = array(
				($vv-0)*0.20+$res['dwd'],
				($vv-0)*604.80+$res['q5fs'],
				($vv-0)*604.80+$res['q5ds'],
				($vv-0)*100.80+$res['q4fs'],
				($vv-0)*100.80+$res['q4ds'],
				($vv-0)*14.40+$res['q3fs'],
				($vv-0)*14.40+$res['q3ds'],
				($vv-0)*1.80+$res['q2fs'],
				($vv-0)*1.80+$res['q2ds'],
				($vv-0)*0.2+$res['q1fs']
			);
		}
		for($i1 = (int)(trim($lv['pk10']));$i1>0.1;$i1-=0.1){
			if(!in_array($i1,$pk101)){
				if(strstr($i1,".")){
					$pk101[] = (string)$i1;
				}else{
					$pk101[] = (string)$i1.".0";
				}
			}
		}
		$pk101[] = '0.0';
		foreach($pk101 as $kk1=>$vv1){
			$n_pk101[$vv1] = array(
				($vv1-0)*0.20+$res['dwd'],
				($vv1-0)*604.80+$res['q5fs'],
				($vv1-0)*604.80+$res['q5ds'],
				($vv1-0)*100.80+$res['q4fs'],
				($vv1-0)*100.80+$res['q4ds'],
				($vv1-0)*14.40+$res['q3fs'],
				($vv1-0)*14.40+$res['q3ds'],
				($vv1-0)*1.80+$res['q2fs'],
				($vv1-0)*1.80+$res['q2ds'],
				($vv1-0)*0.2+$res['q1fs']
			);
		}
		$this->assign("n_pk10",$n_pk10);
		$this->assign("n_pk101",$n_pk101);
		$this->display("rebateDes_PK10");
	}

	 //邀请码管理列表
	 function manageIcode(){
		$uid = $_SESSION['user_id'];
		$leixing = I("leixing");
		$p = I("p");
		$where = " ";
		if($leixing == '1'){
			$where .= " type={$leixing} and";
			$this->assign("leixing",$leixing);
		}elseif($leixing == '2'){
			$where .= " type={$leixing} and ";
			$this->assign("leixing",$leixing);
		}
		if($leixing==''){
			$data = M("agent")->where($where . " uid = {$uid} and type=1")->order("ctime desc")->select();
		}else{
			$data = M("agent")->where($where . " uid = {$uid}")->order("ctime desc")->select();
		}
//分页 begion
		$count = count($data);
		if($count==0){
			$p = 0;
		}else{
			if(empty($p)){
				$p = 1;
			}
		}
		$data = array_slice($data,($p-1)*10,10);
		$totalpage = ceil($count/10);
		$page = $this->page($count,10);
		//end
		foreach($data as $v){
			$code[] = $v["code"];
		}
		$codes = implode(",",$code);
		$date = array();
		if($codes){
			$date = M('Accountsinfo')->where("yq_code in($codes)")->select();
		}
		foreach($data as $k=>$v){
			$data[$k]['num'] = 0;
			foreach($date as $k1=>$v1){
				if($v['code']==$v1['yq_code']){
					$data[$k]['num']++;
				}
			}
		}
		 $data1 = M('Accountsinfo')
				 ->where("userid = '{$uid}'")
				 ->field("yq_code")
				 ->find();
		 if($data1['yq_code']){
			 $date1 = M("agent")->where("code=".$data1['yq_code'])->find();
		 }
		$this->assign("p",$p);
		$this->assign("totalpage",$totalpage);
		$this -> assign("page",$page->show('Admin'));
		$this->assign("count",$count);
		$this->assign("arr",$data);
		 $this->assign("arr1",$date1);
		$this->display();
	}
    //添加备注
	 function remarks(){
		if($_POST){
			$uid = $_SESSION['user_id'];
			$id = I("id");
			$data["remarks"] = I("beizhu");
			M("agent")->where("uid={$uid} and id={$id}")->save($data);
			echo 1;
		}else{
			$this->display();
		}
	}

    //删除code
	 function del_code(){
		$id = I("id");
		$r = M("agent")->where("id={$id}")->delete();
		if($r){
			$this->success("删除成功",U("Users/manageIcode"));
		}else{
			$this->error("删除失败");
		}

	}

	 //验证账号
	 function zhanghao(){
		$id = $_SESSION['user_id'];
		$zhanghao = I("zhanghao");
		$agent = M("agent")->where("uid={$id}")->field("code")->select();//查邀请码
		foreach($agent as $v){
			$code[] = $v["code"];
		}
		$codes = implode(",",$code);
		//查找所有code下注册的账号
		if($codes) {
			$Accountsinfo = M('Accountsinfo')->where("yq_code in($codes)")->field("userid,accounts")->select();
		}

		foreach($Accountsinfo as $v){
			$accounts[] = $v["accounts"];
		}

		if(in_array($zhanghao,$accounts)){
			echo 1;
		}else{
			echo 0;
		}
	}

	 //投注明细
	 function agentBetRecord(){
		$id = $_SESSION['user_id'];
		$agent = M("agent")->where("uid={$id}")->field("code")->select();//查邀请码
		foreach($agent as $v){
			$code[] = $v["code"];
		}
		$codes = implode(",",$code);
		//查找所有code下注册的账号
		if($codes) {
			$Accountsinfo = M('Accountsinfo')->where("yq_code in($codes)")->field("userid,accounts")->select();
		}

	   foreach($Accountsinfo as $v){
		   $uid[] = $v["userid"];
	   }
		$uids = implode(",",$uid);//用户的uid
        $zhanghao = trim(I("zhanghao"));//接收过来的账号
		$caizhong = I("lotteryclass");
		$shijian = I("shijian");
		$leixing = I("leixing");
		$p = I("p");

		$where = array();
		$where['uid'] = array('in',$uids);
		if(!empty($zhanghao)){
			$Accountsinfos = M('Accountsinfo')->where("accounts = '{$zhanghao}'")->field("userid")->find();
			$where['uid'] = $Accountsinfos['userid'];
		}

		if(!empty($caizhong)){
			$where['lotteryclass'] = $caizhong;
		}

		//时间判断
		if($shijian == ''){
			$shijian = '1';
		}
		if($shijian == '1'){
			$stime = date('Y-m-d')." 00:00:00";  //今天开始时间
			$etime = date('Y-m-d')." 23:59:59";//今天结束时间
		}elseif($shijian == '2'){
			$stime = date('Y-m-d',strtotime('-1 day'))." 00:00:00";//昨天开始时间
			$etime = date('Y-m-d',strtotime('-1 day'))." 23:59:59";//昨天结束时间
		}elseif($shijian == '3'){
			$stime = date('Y-m-d',strtotime('-7 day'))." 00:00:00";//7天开始时间
			$etime = date('Y-m-d')." 23:59:59";//7天结束时间
		}
		$stimes = strtotime($stime);
		$etimes = strtotime($etime);
		$where['ctime'] = array(array('egt',$stimes),array('elt',$etimes));
		$this->assign("shijian",$shijian);

		//类型判断
		if($leixing == ''){
			$leixing = '0';
		}

		if($leixing == '0'){
			$this->assign("leixing",$leixing);
		}elseif($leixing == '1'){
			$where['zong_money'] = array('gt',0);
			$this->assign("leixing",$leixing);
		}elseif($leixing == '2'){
			$where['opencode'] = array('neq',"");
			$where['zong_money'] = array('eq',0);
			$this->assign("leixing",$leixing);
		}elseif($leixing == '3'){
			$where['opencode'] = array('eq',"");
			$this->assign("leixing",$leixing);
		}


		//搜索彩票名称
		$classs = M('lottery_class')->select();

		if($uids){
			//列表
			$data1 = M('lottery_add')->where($where) ->select();
			$data2 = M('lottery_11x5')->where($where)->select();
			$data3 = M('lottery_fc3d')->where($where)->select();
			$data4 = M('lottery_kl8')->where($where) ->select();
			$data5 = M('lottery_pk10')->where($where)->select();
			$data6 = M('lottery_ssc')->where($where)->select();
			foreach($data1 as $k=>$v){
				$data1[$k]['table'] = 1;
			}
			foreach($data2 as $k=>$v){
				$data2[$k]['table'] = 2;
			}
			foreach($data3 as $k=>$v){
				$data3[$k]['table'] = 3;
			}
			foreach($data4 as $k=>$v){
				$data4[$k]['table'] = 4;
			}
			foreach($data5 as $k=>$v){
				$data5[$k]['table'] = 5;
			}
			foreach($data6 as $k=>$v){
				$data6[$k]['table'] = 6;
			}
			$data = array_merge($data1,$data2,$data3,$data4,$data5,$data6);
		}

		//列表账号
		foreach($data as $k=>$v){
			foreach($Accountsinfo as $kk=>$vv){
				if($v['uid'] == $vv['userid']){
					$data[$k]["accounts"] = $vv['accounts'];
				}
			}
		}

		//分页 begion
		$count = count($data);
		if($count==0){
			$p = 0;
		}else{
			if(empty($p)){
				$p = 1;
			}
		}
		$data = array_slice($data,($p-1)*10,10);
		$totalpage = ceil($count/10);
		$page = $this->page($count,10);
		//end

		$touzhu = 0;   //投注钱数
		$zhongjiang = 0; //中奖钱数
		$yingli = 0;//盈利钱数
		foreach($data as $v){
			$touzhu += $v["money"];
			$zhongjiang += $v["zong_money"];
			$yingli = $zhongjiang-$touzhu;
		}

		foreach($data as $v){
			$lotteryclass[] = $v["lotteryclass"]; //彩种
			$ids[] = $v["id"];  //内容
		}

		//彩种
		$lotteryclasss = implode(",",$lotteryclass);
		if($lotteryclasss){
			$class = M('lottery_class')->where("id in($lotteryclasss)")->select();
		}

		//内容
		$idss = implode(",",$ids);

		if($idss){
			$lottery_add_detail  = M('lottery_add_detail')->where("lottery_add_id in($idss)")->field("lottery_add_id,cal,is_zhong")->select();
			$lottery_11x5_detail = M('lottery_11x5_detail')->where("lottery_11x5_id in($idss)")->field("lottery_11x5_id,cal,is_zhong")->select();
			$lottery_fc3d_detail = M('lottery_fc3d_detail')->where("lottery_fc3d_id in($idss)")->field("lottery_fc3d_id,cal,is_zhong")->select();
			$lottery_kl8_detail = M('lottery_kl8_detail')->where("lottery_kl8_id in($idss)")->field("lottery_kl8_id,cal,is_zhong")->select();
			$lottery_pk10_detail = M('lottery_pk10_detail')->where("lottery_pk10_id in($idss)")->field("lottery_pk10_id,cal,is_zhong")->select();
			$lottery_ssc_detail = M('lottery_ssc_detail')->where("lottery_ssc_id in($idss)")->field("lottery_ssc_id,cal,is_zhong")->select();
		}

		$a1 = array();
		foreach($lottery_add_detail as $v){
			//内容
			if(isset($a1[$v["lottery_add_id"]])){
				$a1[$v["lottery_add_id"]] = $a1[$v["lottery_add_id"]].'#'.$v["cal"];
			}else{
				$a1[$v["lottery_add_id"]] = $v["cal"];
			}
		}
		$a2 = array();
		foreach($lottery_11x5_detail as $v){
			//内容
			if(isset($a2[$v["lottery_11x5_id"]])){
				$a2[$v["lottery_11x5_id"]] = $a2[$v["lottery_11x5_id"]].'#'.$v["cal"];
			}else{
				$a2[$v["lottery_11x5_id"]] = $v["cal"];
			}
		}
		$a3 = array();
		foreach($lottery_fc3d_detail as $v){
			//内容
			if(isset($a3[$v["lottery_fc3d_id"]])){
				$a3[$v["lottery_fc3d_id"]] = $a3[$v["lottery_fc3d_id"]].'#'.$v["cal"];
			}else{
				$a3[$v["lottery_fc3d_id"]] = $v["cal"];
			}
		}
		$a4 = array();
		foreach($lottery_kl8_detail as $v){
			//内容
			if(isset($a4[$v["lottery_kl8_id"]])){
				$a4[$v["lottery_kl8_id"]] = $a4[$v["lottery_kl8_id"]].'#'.$v["cal"];
			}else{
				$a4[$v["lottery_kl8_id"]] = $v["cal"];
			}
		}
		$a5 = array();
		foreach($lottery_pk10_detail as $v){
			//内容
			if(isset($a5[$v["lottery_pk10_id"]])){
				$a5[$v["lottery_pk10_id"]] = $a5[$v["lottery_pk10_id"]].'#'.$v["cal"];
			}else{
				$a5[$v["lottery_pk10_id"]] = $v["cal"];
			}
		}
		$a6 = array();
		foreach($lottery_ssc_detail as $v){
			//内容
			if(isset($a6[$v["lottery_ssc_id"]])){
				$a6[$v["lottery_ssc_id"]] = $a6[$v["lottery_ssc_id"]].'#'.$v["cal"];
			}else{
				$a6[$v["lottery_ssc_id"]] = $v["cal"];
			}
		}


		foreach($data as $k=>$v){
			foreach($class as $kk=>$vv){
				if($v["lotteryclass"] == $vv["id"]){
					$data[$k]["classname"] = $vv["name"];
				}
			}
		}
		$this->assign("caizhong",$caizhong);
		$this->assign("zhongjiang",$zhongjiang);
		$this->assign("yingli",$yingli);
		$this->assign("touzhu",$touzhu);
		$this->assign("count",$count);
		$this->assign("a1",$a1);
		$this->assign("a2",$a2);
		$this->assign("a3",$a3);
		$this->assign("a4",$a4);
		$this->assign("a5",$a5);
		$this->assign("a6",$a6);
		$this->assign("arr",$data);
		$this->assign("zhanghao",$zhanghao);

		$this->assign("p",$p);
		$this->assign("totalpage",$totalpage);
		$this -> assign("page",$page->show('Admin'));
		$this->assign("classs",$classs);
		$this->assign("id",$id);
		$this->display();
	}
     //会员管理
	 function agentMember(){
	 	$typ = I("typ");
	 	if($typ=='1'){
	 		$id = I("uid");
	 		$sh = M("Accountsinfo")->where("userid = $id")->field("accounts")->find();
			if($_SESSION["nam"]){
				if(!in_array($sh['accounts'], $_SESSION['art'])){
					session("nam",$_SESSION["nam"].">".$sh['accounts']);
					$_SESSION['art'][] = $sh['accounts'];
				}
			}else{
				session("nam",$sh['accounts']);
				$_SESSION['art'][] = $sh['accounts'];
			}
			$this->assign("sh",$_SESSION['art']);
	 	}else if($typ=='2'){
			$idz = I("userid");
			$uid2 = $_SESSION['user_id'];
			//上级id
			$sf = M("Accountsinfo")->where("userid = $idz")->field("userid,accounts,yq_code")->find();
			if($sf['yq_code']){
				$sg = M("agent")->where("code = '{$sf['yq_code']}'")->field("uid")->find();
			}

			$id = $sg['uid'];
			if($uid2==$id){
				$_SESSION['art'] = array();
			}else{
				foreach($_SESSION['art'] as $kk=>$vv){
					if($vv == $sf['accounts']){
						unset($_SESSION['art'][$kk]);
					}
				}
			}	
			$this->assign("sh",$_SESSION['art']);
		}else{
	 		$id = $_SESSION['user_id'];
	 		session("nam",null);
			session("art",null);
	 	}
		
		$wanjia = M('Accountsinfo')->where("userid = {$id}")->field("utype")->find();
		$p = I("p");
        $zhanghao = I("zhanghao");
		$leixing = I("leixing");
		$where = array();
		if(!empty($leixing)){
			$where['utype'] = $leixing;
		}
		if(!empty($zhanghao)){
			$where['Accounts'] = $zhanghao;
		}

		$agent = M("agent")->where("uid={$id}")->field("code")->select();//查邀请码

		foreach($agent as $v){
			$code[] = $v["code"];
		}
		$codes = implode(",",$code);

		//查找所有code下注册的账号
         if(!empty($codes)){
			 $where['yq_code'] = array('in',$codes);
			 $Accountsinfo = M('Accountsinfo')->where($where)->field("userid,accounts,yq_code,utype,lasttime,money")->select();
		 }else{}

		//分页 begion
		$count = count($Accountsinfo);
		if($count==0){
			$p = 0;
		}else{
			if(empty($p)){
				$p = 1;
			}
		}
		$Accountsinfo = array_slice($Accountsinfo,($p-1)*10,10);
		$totalpage = ceil($count/10);
		$page = $this->page($count,10);
		//end
		$uidd = array();
		foreach($Accountsinfo as $v){
			$yq_codes[] = $v["yq_code"];
			$uidd[] = $v['userid'];
		}
		$code= implode(",",$yq_codes);
        $uids = implode(",",$uidd);


		if($uids){
			$agents = M("agent g")
				->join(" join ".C("DB_PREFIX")."accountsinfo a on g.code=a.yq_code")
				->where("g.uid in($uids)")
				->field("g.*")
				->select();
		}
        if($code){
		$cod = M("agent")->where("code in($code)")->select();
		}
		foreach($Accountsinfo as $k=>$v){
			foreach($cod as $kk=>$vv){
				if($v["yq_code"] == $vv["code"]){
					$Accountsinfo[$k]['ssc'] = $vv['ssc'];
					$Accountsinfo[$k]['k3'] = $vv['k3'];
					$Accountsinfo[$k]['x11_5'] = $vv['x11_5'];
					$Accountsinfo[$k]['fc3d'] = $vv['fc3d'];
					$Accountsinfo[$k]['pl3_5'] = $vv['pl3_5'];
					$Accountsinfo[$k]['kl8'] = $vv['kl8'];
					$Accountsinfo[$k]['pk10'] = $vv['pk10'];
				}
			}
		}
		foreach($Accountsinfo as $k=>$v){
			$Accountsinfo[$k]['num'] = 0;
			foreach($agents as $k1=>$v1){
				if($v['userid']==$v1['uid']){
					$Accountsinfo[$k]['num']++;
				}
			}
		}
		$data1 = M('Accountsinfo')
				 ->where("userid = '{$id}'")
				 ->field("yq_code")
				 ->find();
		 if($data1['yq_code']){
			 $date1 = M("agent")->where("code=".$data1['yq_code'])->find();
		 }

		$this->assign("arr1",$date1);
		$this->assign("wanjia",$wanjia);
		$this->assign("zhanghao",$zhanghao);
		$this->assign("leixing",$leixing);
		$this->assign("p",$p);
		$this->assign("totalpage",$totalpage);
		$this->assign("page",$page->show('Admin'));
		$this->assign("arr",$Accountsinfo);
		$this->display();
	}

     //交易记录
	 function BillRecord(){
		$id = $_SESSION['user_id'];
		 $wanjia = M('Accountsinfo')->where("userid = {$id}")->field("utype")->find();

		 $type = I("zhaiyao");
		$shijian = I("shijian");
		$zhuangtai = I("zhuangtai");
		$p = I("p");

		$where = array();
		$where['uid'] = $id;
		if(!empty($type)){
			$where['type'] = $type;
		}
		//时间判断
		if($shijian == ''){
			$shijian = '1';
		}
		if($shijian == '1'){
			$stime = date('Y-m-d')." 00:00:00";  //今天开始时间
			$etime = date('Y-m-d')." 23:59:59";//今天结束时间
		}elseif($shijian == '2'){
			$stime = date('Y-m-d',strtotime('-1 day'))." 00:00:00";//昨天开始时间
			$etime = date('Y-m-d',strtotime('-1 day'))." 23:59:59";//昨天结束时间
		}elseif($shijian == '3'){
			$stime = date('Y-m-d',strtotime('-7 day'))." 00:00:00";//7天开始时间
			$etime = date('Y-m-d')." 23:59:59";//7天结束时间
		}
		$stimes = strtotime($stime);
		$etimes = strtotime($etime);
		$where['ctime'] = array(array('egt',$stimes),array('elt',$etimes));
		$this->assign("shijian",$shijian);

//类型判断
		if($zhuangtai == ''){
			$zhuangtai = '0';
		}
		if($zhuangtai == '0'){
			$this->assign("leixing",$zhuangtai);
		}elseif($zhuangtai == '1'){
			$where['type'] = array('eq',1);
			$this->assign("leixing",$zhuangtai);
		}elseif($zhuangtai == '2'){
			$where['type'] = array('eq',2);
			$where['type'] = array('eq',6);
			$where['type'] = array('eq',9);
			$this->assign("leixing",$zhuangtai);
		}

		$data = M("jiaoyi")->where($where)->select();
//分页 begion
		$count = count($data);
		if($count==0){
			$p = 0;
		}else{
			if(empty($p)){
				$p = 1;
			}
		}
		$data = array_slice($data,($p-1)*10,10);
		$totalpage = ceil($count/10);
		$page = $this->page($count,10);
		//end
		 $this->assign("wanjia",$wanjia);
		$this->assign("type",$type);
		$this->assign("p",$p);
		$this->assign("totalpage",$totalpage);
		$this -> assign("page",$page->show('Admin'));
		$this->assign("arr",$data);
		$this->assign("id",$id);
		$this->display();
	}

	//今日盈亏
	function PLstatement(){
		$id = $_SESSION['user_id'];
		$wanjia = M('Accountsinfo')->where("userid = {$id}")->field("utype")->find();
		$data = M('Accountsinfo')->where("userid={$id}")->field("money")->find();
		$mone = sprintf("%.2f",$data['money']);//余额

		//投注花的钱

		$begintime=date("Y-m-d H:i:s",mktime(0,0,0,date('m'),date('d'),date('Y')));
		$endtime=date("Y-m-d H:i:s",mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1);
        $kaishi = strtotime($begintime); //条件 开始时间
		$jieshu = strtotime($endtime); //条件 结束时间
		$time = time();
		$touzhu = M("jiaoyi")->where("uid = {$id} and type=3 and {$kaishi}<={$time} and {$time}<={$jieshu}")->field("zhi_money")->select();
		$zong_zhi = 0;
       foreach($touzhu as $v) {
		   $zong_zhi += $v['zhi_money'];
	   }
       $zhichu = sprintf("%.2f",$zong_zhi);//投注扣款的钱

		//返点的钱
		$fandian = M("jiaoyi")->where("uid = {$id} and type=4")->field("shou_money")->select();
		$zong_shou = 0;
		foreach($fandian as $v) {
			$zong_shou += $v['shou_money'];
		}
		$shou = sprintf("%.2f",$zong_shou);//返点的钱

       //活动的钱
		$huodong = M("jiaoyi")->where("uid = {$id} and type=7 and {$kaishi}<={$time} and {$time}<={$jieshu}")->field("shou_money")->select();
		$zong_shou1 = 0;
		foreach($huodong as $v) {
			$zong_shou1 += $v['shou_money'];
		}
		$shou2 = sprintf("%.2f",$zong_shou1);//活动的钱

      //中奖的钱
		$zhongjiang = M("jiaoyi")->where("uid = {$id} and type=5 and {$kaishi}<={$time} and {$time}<={$jieshu}")->field("shou_money")->select();
		$zong_shou2 = 0;
		foreach($zhongjiang as $v) {
			$zong_shou2 += $v['shou_money'];
		}
		$shou3 = sprintf("%.2f",$zong_shou2);//中奖的钱

	//充值的钱
		$chongzhi = M("jiaoyi")->where("uid = {$id} and type=1 and {$kaishi}<={$time} and {$time}<={$jieshu}")->field("shou_money")->select();
		$zong_shou5 = 0;
		foreach($chongzhi as $v) {
			$zong_shou5 += $v['shou_money'];
		}
		$chong = sprintf("%.2f",$zong_shou5);//充值的钱
  //提现金额
		$tixian = M("jiaoyi")->where("uid = {$id} and type=2 and {$kaishi}<={$time} and {$time}<={$jieshu}")->field("zhi_money")->select();
		$zong_shou6 = 0;
		foreach($tixian as $v) {
			$zong_shou6 += $v['zhi_money'];
		}
		$tixian2 = sprintf("%.2f",$zong_shou6);//充值的钱



		//盈亏总额
		$yingkui = $shou3-$zhichu+$shou+$shou2;
		$yingkuis = sprintf("%.2f",$yingkui);

		$this->assign("tixian2",$tixian2);
		$this->assign("shou",$shou);
		$this->assign("chong",$chong);
		$this->assign("shou2",$shou2);
		$this->assign("shou3",$shou3);
        $this->assign("zhichu",$zhichu);
		$this->assign("yingkuis",$yingkuis);
		$this->assign("mone",$mone);
		$this->assign("wanjia",$wanjia);
		$this->assign("id",$id);
		$this->display();
	}



     //交易明细
	 function agentBillRecord(){
		//查找下级账户 begian
		$id = $_SESSION['user_id'];

		$agent = M("agent")->where("uid={$id}")->field("code")->select();//查邀请码

		foreach($agent as $v){
			$code[] = $v["code"];
		}
		$codes = implode(",",$code);
		//查找所有code下注册的账号
		if($codes) {
			$Accountsinfo = M('Accountsinfo')->where("yq_code in($codes)")->field("userid,accounts")->select();
		}else{
			$Accountsinfo = M('Accountsinfo')->where("userid = {$id}")->field("userid,accounts")->select();
		}

		foreach($Accountsinfo as $v){
			$uid[] = $v["userid"];
		}
		$uids = implode(",",$uid);//用户的uid
		//查找下级账户 end


		$zhanghao = trim(I("zhanghao"));//接收过来的账号
		$type = I("zhaiyao");
		$shijian = I("shijian");
		$zhuangtai = I("zhuangtai");
		$p = I("p");

		$where = array();
        if($uids){
			$where['uid'] = array('in',$uids);
		}
		if(!empty($zhanghao)){
			$Accountsinfos = M('Accountsinfo')->where("accounts = '{$zhanghao}'")->field("accounts,userid")->find();
			$where['uid'] = $Accountsinfos['userid'];
		}

		if(!empty($type)){
			$where['type'] = $type;
		}

		//时间判断
		if($shijian == ''){
			$shijian = '1';
		}
		if($shijian == '1'){
			$stime = date('Y-m-d')." 00:00:00";  //今天开始时间
			$etime = date('Y-m-d')." 23:59:59";//今天结束时间
		}elseif($shijian == '2'){
			$stime = date('Y-m-d',strtotime('-1 day'))." 00:00:00";//昨天开始时间
			$etime = date('Y-m-d',strtotime('-1 day'))." 23:59:59";//昨天结束时间
		}elseif($shijian == '3'){
			$stime = date('Y-m-d',strtotime('-7 day'))." 00:00:00";//7天开始时间
			$etime = date('Y-m-d')." 23:59:59";//7天结束时间
		}
		$stimes = strtotime($stime);
		$etimes = strtotime($etime);
		$where['ctime'] = array(array('egt',$stimes),array('elt',$etimes));
		$this->assign("shijian",$shijian);

//类型判断
		if($zhuangtai == ''){
			$zhuangtai = '0';
		}
		if($zhuangtai == '0'){
			$this->assign("leixing",$zhuangtai);
		}elseif($zhuangtai == '1'){
			$where['type'] = array('eq',1);
			$this->assign("leixing",$zhuangtai);
		}elseif($zhuangtai == '2'){
			$where['type'] = array('eq',2);
			$where['type'] = array('eq',6);
			$where['type'] = array('eq',9);
			$this->assign("leixing",$zhuangtai);
		}

		$data = M("jiaoyi")->where($where)->select();
        foreach($data as $v){
			$uidss[] = $v['uid'];
		}
		 $uidsss = implode(",",$uidss);
       if($uidsss){
		   $Accountsinfo22 = M('Accountsinfo')->where("userid in ($uidsss)")->field("accounts,userid")->select();
	   }
//        dump($Accountsinfo22);die;
//分页 begion
		$count = count($data);
		if($count==0){
			$p = 0;
		}else{
			if(empty($p)){
				$p = 1;
			}
		}
		$totalpage = ceil($count/10);
		$page = $this->page($count,10);
		//end
         //账号
		foreach($data as $k=>$v){
			foreach($Accountsinfo22 as $kk=>$vv){
				if($v["uid"] == $vv["userid"]){
					$data[$k]['zhanghao'] = $vv['accounts'];
				}
			}
		}
//         dump($data);die;
		$this->assign("type",$type);
		$this->assign("p",$p);
		$this->assign("totalpage",$totalpage);
		$this -> assign("page",$page->show('Admin'));
		$this->assign("arr",$data);
		$this->assign("zhanghao",$zhanghao);
		$this->assign("id",$id);
		$this->display();
	}

     //活动中心
	  //晋级奖励
	  function activity(){
		  $id = $_SESSION['user_id'];
		  $Accountsinfo = M('Accountsinfo')->where("userid = {$id}")->field("score")->select();
          $jiangjin = I("jiangjin");
		  $dat['kl_money'] = $jiangjin;
		  $dat['is_lingqu'] = 1;
		  $dat['lq_time'] = time();
          M("up_level")->where("uid={$id}")->save($dat);

          $this->assign("arr",$Accountsinfo);
		  $this->assign("id",$id);
          $this->display();
	  }


	//站内信
		function letter(){
			$id = $_SESSION['user_id'];
			$p = I("p");
			$wanjia = M('Accountsinfo')->where("userid = {$id}")->field("utype")->find();
			if($id){
				$data = M("tixian")->where("uid={$id} and ti_time!=0 and is_ti!=0")->field("is_ti,money,ti_time")->select();
			}
			//分页 begion
			$count = count($data);
			if($count==0){
				$p = 0;
			}else{
				if(empty($p)){
					$p = 1;
				}
			}
			$data = array_slice($data,($p-1)*10,10);
			$totalpage = ceil($count/10);
			$page = $this->page($count,10);
			//end

			$this->assign("p",$p);
			$this->assign("totalpage",$totalpage);
			$this -> assign("page",$page->show('Admin'));
			$this->assign("arr",$data);
			$this->assign("wanjia",$wanjia);
			$this->assign("id",$id);
			$this->display();
			}
	//网站公告
		function Notice(){
				$id = $_SESSION['user_id'];
				$wanjia = M('Accountsinfo')->where("userid = {$id}")->field("utype")->find();
                $data = M("notice")->select();
			    $p = I("p");
			   //分页 begion
					$count = count($data);
					if($count==0){
						$p = 0;
					}else{
						if(empty($p)){
							$p = 1;
						}
					}
					$data = array_slice($data,($p-1)*10,10);
					$totalpage = ceil($count/10);
					$page = $this->page($count,10);
				//end


				$this->assign("p",$p);
				$this->assign("totalpage",$totalpage);
				$this -> assign("page",$page->show('Admin'));
			    $this->assign("arr",$data);
				$this->assign("wanjia",$wanjia);
				$this->assign("id",$id);
				$this->display();
			}
   //网站公告详情
	function NoticeDetail(){
		$uid = $_SESSION['user_id'];
		$id = I("id");
		$wanjia = M('Accountsinfo')->where("userid = {$uid}")->field("utype")->find();
		if($id){
			$data = M("notice")->where("id={$id}")->select();
		}

		$this->assign("arr",$data);
		$this->assign("wanjia",$wanjia);
		$this->assign("id",$id);
		$this->display();
	}
	function getlastMonthDays($date){
	     $timestamp=strtotime("2017-09-15");
	     $firstday=date('Y-m-01',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)-1).'-01'));
	     $lastday=date('Y-m-d',strtotime("$firstday +1 month -1 day"));
	     return array($firstday,$lastday);
	 }
	//下级报表
	public function lowerReport(){
		$lab = I("lab");
		$p = I("p");
		$shijian = I("shijian");
		//时间判断
		if($shijian == ''){
			$shijian = '1';
		}
		if($shijian == '1'){
			$stime = date('Y-m-d')." 00:00:00";  //今天开始时间
			$etime = date('Y-m-d')." 23:59:59";//今天结束时间
		}elseif($shijian == '2'){
			$stime = date('Y-m-d',strtotime('-1 day'))." 00:00:00";//昨天开始时间
			$etime = date('Y-m-d',strtotime('-1 day'))." 23:59:59";//昨天结束时间
		}elseif($shijian == '3'){
			$stime = date("Y-m-d",strtotime("-1 month"))." 00:00:00";//本月开始时间
			$etime = date('Y-m-d')." 23:59:59";//结束时间
		}else{
			$de = date("Y-m-d");
			$cr = self::getlastMonthDays($de);
			$stime = $cr[0]." 00:00:00";  //今天开始时间
			$etime = $cr[1]." 23:59:59";//今天结束时间
		}
		$stimes = strtotime($stime);
		$etimes = strtotime($etime);
		$where['ctime'] = array(array('egt',$stimes),array('elt',$etimes));
		$this->assign("shijian",$shijian);

		if($lab=='1'){
			$uid = I("userid");
			$sh = M("Accountsinfo")->where("userid = $uid")->field("accounts")->find();
			if($_SESSION["nam"]){
				if(!in_array($sh['accounts'], $_SESSION['art'])){
					session("nam",$_SESSION["nam"].">".$sh['accounts']);
					$_SESSION['art'][] = $sh['accounts'];
				}
			}else{
				session("nam",$sh['accounts']);
				$_SESSION['art'][] = $sh['accounts'];
			}
			$this->assign("sh",$_SESSION['art']);
		}else if($lab=='2'){
			$uid1 = I("userid");
			$uid2 = $_SESSION['user_id'];
			//上级id
			$sf = M("Accountsinfo")->where("userid = $uid1")->field("userid,accounts,yq_code")->find();
			if($sf['yq_code']){
				$sg = M("agent")->where("code = '{$sf['yq_code']}'")->field("uid")->find();
			}
			$uid = $sg['uid'];
			if($uid2==$uid){
				$_SESSION['art'] = array();
			}else{
				foreach($_SESSION['art'] as $kk=>$vv){
					if($vv == $sf['accounts']){
						unset($_SESSION['art'][$kk]);
					}
				}
			}	
			$this->assign("sh",$_SESSION['art']);
		}else{
			$uid = $_SESSION['user_id'];
			session("nam",null);
			session("art",null);
		}
		$c = M('agent')->where("uid = {$uid}")->field("code")->select();
		$ce = array();
		foreach($c as $k=>$v){
			$ce[] = $v['code'];
		}
		$co = implode(",",$ce);
		if($co){
			$count = M('Accountsinfo')
				->where("yq_code in({$co})")
				->count();
			if($count==0){
				$p = 0;
			}else{
				if(empty($p)){
					$p = 1;
				}
			}
			$totalpage = ceil($count/10);
			$page = $this->page($count,10);
			$wanjia = M('Accountsinfo')
				->where("yq_code in({$co})")
				->limit($page->firstRow, $page->listRows)
				->field("userid,accounts,utype,yq_code")
				->select();
			$this->assign("page",$page->show('Admin'));
		}else{
			$p = 0;
			$totalpage = 0;
		}
		$ue = array();
		foreach($wanjia as $k=>$v){
			$ue[] = $v['userid'];
		}
		$stu = implode(",",$ue);
		if($stu){
			$where['uid'] = array("in",$stu);
			$jy = M("jiaoyi")->where($where)->select();
			//下级的下级
			$c1 = M('agent')->where("uid in($stu)")->field("uid,code")->select();
			foreach($wanjia as $kx=>$vx){
				foreach($c1 as $kxx=>$vxx){
					if($vx['userid']==$vxx['uid']){
						$wanjia[$kx]['code'][] = $vxx['code'];
					}
				}
			}
			$ce1 = array();
			foreach($c1 as $k1=>$v1){
				$ce1[] = $v1['code'];
			}
			$co1 = implode(",",$ce1);
			if($co1){
				$wanjia1 = M('Accountsinfo')->where("yq_code in({$co1})")->field("userid,accounts,utype,yq_code")->select();
				foreach($wanjia as $kx1=>$vx1){
					foreach($wanjia1 as $kx2=>$vx2){
						if(in_array($vx2['yq_code'],$vx1['code'])){
							$wanjia[$kx1]['xj_user'][] = $vx2['userid'];
						}
					}
				}
				$zxc = array();
				foreach($wanjia1 as $ko=>$vo){
					$zxc[] = $vo['userid'];
				}
				$zz = implode(",",$zxc);
				$where1['uid'] = array("in",$zz);
				$where1['ctime'] = array(array('egt',$stimes),array('elt',$etimes));
				$jyq = M("jiaoyi")->where($where1)->select();
			}
		}
		$ext = array();
		foreach($wanjia as $ka=>$va){
			$m = 0;//投注
			$n = 0;//中奖
			$a = 0;//返点
			$b = 0;//活动
			$x = 0;//下级
			foreach($jy as $kk=>$vv){
				if($va['userid']==$vv['uid']){
					if($vv['type']=='3'){
						$m+=$vv['zhi_money'];
					}
					if($vv['type']=='5'){
						$n+=$vv['shou_money'];
					}
					if($vv['type']=='4'){
						$a+=$vv['shou_money'];
					}
					if($vv['type']=='7'){
						$b+=$vv['shou_money'];
					}
				}
			}
			foreach($jyq as $ki=>$vi){
				if($vi['type']=='3'){
					if(in_array($vi['uid'],$va['xj_user'])){
						if(!in_array($vi['uid'],$ext)){
							$x++;
							$ext[] = $vi['uid'];
						}
					}
				}
			}
			$wanjia[$ka]['touzhu'] = $m;
			$wanjia[$ka]['zhongjiang'] = $n;
			$wanjia[$ka]['fandian'] = $a;
			$wanjia[$ka]['huodong'] = $b;
			$wanjia[$ka]['yingli'] = $n+$a+$b-$m;
			$wanjia[$ka]['xj'] = $x;
		}
		$this->assign("wanjia",$wanjia);
		$this->assign("p",$p);
		$this->assign("totalpage",$totalpage);
		$this->display();
	}
	//根据name获取id
	public function get_id(){
		$name = I("name");
		$res = M("accountsinfo")->where("accounts = '{$name}'")->field("userid")->find();
		if($res){
			echo json_encode($res['userid']);
		}else{
			echo json_encode("");
		}
	}
	//代理报表

	public function agentReport(){
		//查询
		$shijian = I("shijian");
		$zhanghao = trim(I("zhanghao"));

		//时间判断
		if($shijian == ''){
			$shijian = '1';
		}
		if($shijian == '1'){
			$stime = date('Y-m-d')." 00:00:00";  //今天开始时间
			$etime = date('Y-m-d')." 23:59:59";//今天结束时间
		}elseif($shijian == '2'){
			$stime = date('Y-m-d',strtotime('-1 day'))." 00:00:00";//昨天开始时间
			$etime = date('Y-m-d',strtotime('-1 day'))." 23:59:59";//昨天结束时间
		}elseif($shijian == '3'){ //本月的开始时间和结束时间
			$y=date("Y",time());
			$m=date("m",time());
			$t0=date('t');           // 本月一共有几天
			$stime0=mktime(0,0,0,$m,1,$y);        // 创建本月开始时间
			$etime0=mktime(23,59,59,$m,$t0,$y);       // 创建本月结束时间
			$stime = date('Y-m-d H:i:s',$stime0);
			$etime = date('Y-m-d H:i:s',$etime0);
		}elseif($shijian == '4'){ //上个月的开始时间和结束时间
			$m = date('m');
			$y = date('Y');
			if ($m == 1) {
				$lastmonth = 12;
				$lastyear = $y - 1;
			} else {
				$lastmonth = $m - 1;
				$lastyear = $y;
			}
			$stime = $lastyear . '-' . $lastmonth . '-1'." "."00:00:00";
			$etime = $lastyear . '-' . $lastmonth . '-' . date('t', strtotime($stime))." "."23:59:59";
		}

		$stimes = strtotime($stime);
		$etimes = strtotime($etime);

		$this->assign("shijian",$shijian);


        $id  = $_SESSION['user_id'];//总id
		$uid1 = M("Accountsinfo")->where("accounts = '{$zhanghao}'")->field("userid")->find();
        $uid = $uid1['userid'];
		if($uid){
			$zj = M("Accountsinfo ac")
					->where("userid={$uid}")
					->field("ac.userid,ac.yq_code")
					->find();  //查出自己的uid  自己注册时的yq_code
		}else{
			$zj = M("Accountsinfo ac")
					->where("userid={$id}")
					->field("ac.userid,ac.yq_code")
					->find();  //查出自己的uid  自己注册时的yq_code
		}

		$code = M("agent")->field("uid,code")->select();//查下 agent 表中 所有的 UID code
		$zj['code'] = array();// 定义一个数组

		foreach($code as $k1=>$v1){//把该账号生成的 code 放在 同一个数组里
			if($zj['userid'] == $v1['uid']){
				$zj['code'][] = $v1['code'];
				unset($code[$k1]);
			}
		}
		//查出所有的uid  注册时的yq_code
		if($uid){
			$sy = M("Accountsinfo ")->where("userid != {$uid}")->field("userid,yq_code")->select();
		}else{
			$sy = M("Accountsinfo ")->where("userid != {$id}")->field("userid,yq_code")->select();
		}

		//双层循环 得到 不是该账号生成的 code
		foreach($sy as $k=>$v){
			$sy[$k]['code'] = array();//定义一个数组
			foreach($code as $k1=>$v1){
				if($v['userid'] == $v1['uid']){
					$sy[$k]['code'][] = $v1['code'];//把所有的不等于当前账号生成的code 放在 ￥sy 数组里;
					unset($code[$k1]);
				}
			}
		}

		$user = array();//定义一个数组
		$user[] = $zj['userid']; //把自己的用户id 放进去
		$code =  $zj['code']; //换下名字

		for($i=1;$i==1;){
			$j = 0;
			foreach($sy as $k=>$v){
				if(in_array($v['yq_code'],$code)){
					$user[] = $v['userid']; //把UID 放在$user 数组里
					$code = array_merge($v['code'],$code); // 数组合并
					unset($sy[$k]);
					$j = 1;
				}
			}
			if($j==0){
				$i++;
			}
		}
		$uids = implode(",",$user);
	//下级人数
	  $count = count($user);

    //注册人数
		$jiaoyi_zc = M("Accountsinfo")->where("userid in ($uids) and {$stimes} <= ctime and ctime<={$etimes}")->select();
		$count_zc = count($jiaoyi_zc);

	//投注
       if($uids){
		   $jiaoyi_tz = M("jiaoyi")->where("uid in ($uids) and type=3 and {$stimes} <= ctime and ctime<={$etimes}")->field("zhi_money")->select();
	   }
		$touzhu = 0;
       foreach($jiaoyi_tz as $v){
		   $touzhu += $v['zhi_money'];
	   }
    //中奖
		if($uids){
			$jiaoyi_zj = M("jiaoyi")->where("uid in ($uids) and type=5 and {$stimes} <= ctime and ctime<={$etimes}")->field("shou_money")->select();
		}
		$zhongjiang = 0;
		foreach($jiaoyi_zj as $v){
			$zhongjiang += $v['shou_money'];
		}
    //活动礼金
		if($uids){
			$jiaoyi_hd = M("jiaoyi")->where("uid in ($uids) and type=7 and {$stimes} <= ctime and ctime<={$etimes}")->field("shou_money")->select();
		}
		$huodong = 0;
		foreach($jiaoyi_hd as $v){
			$huodong += $v['shou_money'];
		}
    //团队和代理返点
		if($uids){
			$jiaoyi_fd = M("jiaoyi")->where("uid in ($uids) and type=4 and {$stimes} <= ctime and ctime<={$etimes}")->field("shou_money")->select();
		}
		$fandian = 0;
		foreach($jiaoyi_fd as $v){
			$fandian += $v['shou_money'];
		}

	//盈利
		$yingli  = $zhongjiang + $huodong + $fandian - $touzhu;


    //团队余额
		if($uids){
			$jiaoyi_yue = M("Accountsinfo")->where("userid in ($uids)")->field('money')->select();
		}
		$yue = 0;
		foreach($jiaoyi_yue as $v){
			$yue += $v['money'];
		}

   //投注人数
		if($uids){
			$jiaoyi_rs = M("jiaoyi")->where("uid in ($uids) and type=3 and {$stimes} <= ctime and ctime<={$etimes}")->distinct(true)->field('uid')->select();
		}
        $renshu = 0;
		foreach($jiaoyi_rs as $v){
			$renshu += count($v['uid']);
		}
   //充值金额
		if($uids){
			$jiaoyi_cz = M("jiaoyi")->where("uid in ($uids) and type=1 and {$stimes} <= ctime and ctime<={$etimes}")->field("shou_money")->select();
		}
		$chongzhi = 0;
		foreach($jiaoyi_cz as $v){
			$chongzhi += $v['shou_money'];
		}
    //提现金额
		if($uids){
			$jiaoyi_tx = M("jiaoyi")->where("uid in ($uids) and type=2 and {$stimes} <= ctime and ctime<={$etimes}")->field("zhi_money")->select();
		}
		$tixian = 0;
		foreach($jiaoyi_tx as $v){
			$tixian += $v['zhi_money'];
		}

    //首冲人数
		function FetchRepeatMemberInArray($array) {
			// 获取去掉重复数据的数组
			$unique_arr = array_unique ( $array );
			// 获取重复数据的数组
			$repeat_arr = array_diff_assoc ( $array, $unique_arr );
			return $repeat_arr;
		} //获取数组中重复的数据 (这是一个封装的函数)

		if($uids){
			$jiaoyi_sc = M("jiaoyi")->where("uid in ($uids) and type=1 and {$stimes} <= ctime and ctime<={$etimes}")->field("uid")->select();
		}

		foreach($jiaoyi_sc as $v){
			$cc[] = $v['uid'];
		}
        $meiyou_cz = M("Accountsinfo")->where("userid in ($uids) and score=0")->field("userid")->select();

		foreach($meiyou_cz as $v){
			$meiyou_cz2[] = $v['userid'];
		}

		$chongfu_uid = FetchRepeatMemberInArray($cc);//有重复的UID
        $uidss = explode(",",$uids);//把原先获取到的UID字符串变为一个数组
        $count1_sc = array_diff($uidss,$chongfu_uid);//求两个数组的差集  array_diff()
		$count_sc = count(array_diff($count1_sc,$meiyou_cz2));



     $this->assign("zhanghao",$zhanghao);
	 $this->assign("count_zc",$count_zc);
	 $this->assign("count_sc",$count_sc);
     $this->assign("count",$count);
	 $this->assign("tixian",$tixian);
	 $this->assign("chongzhi",$chongzhi);
	 $this->assign("renshu",$renshu);
	 $this->assign("yingli",$yingli);
	 $this->assign("yue",$yue);
	 $this->assign("fandian",$fandian);
	 $this->assign("huodong",$huodong);
	 $this->assign("zhongjiang",$zhongjiang);
     $this->assign("touzhu",$touzhu);
     $this->display();
	}
	/*
	 * kon
	 */
	public function shuax(){

	}
}